VBScript VarType Function

|  | Search W3Schools : |

HOME | HTML | CSS | XML | JAVASCRIPT | ASP | PHP | SQL | MORE... |  | References | Examples | Forum | About

ADVERTISEMENTS XML Certification Download XML editor Custom Programming |  |

Table of contents

VBScript Tutorial
VB HOME
VB Introduction
VB How to
VB Where to
VB Variables
VB Procedures
VB Conditional
VB Looping
VB Summary
Examples
VB Examples
References
VB Functions
VB Keywords

Selected Reading

Web Statistics
Web Glossary
Web Hosting
Web Quality
W3Schools Tutorials
W3Schools Forum
Helping W3Schools

# VBScript VarType Function

Complete VBScript Reference

The VarType function returns a value that indicates the subtype of a specified variable.

The VarType function can return one of the following values:

- 0 = vbEmpty - Indicates Empty (uninitialized)
- 1 = vbNull - Indicates Null (no valid data)
- 2 = vbInteger - Indicates an integer
- 3 = vbLong - Indicates a long integer
- 4 = vbSingle - Indicates a single-precision floating-point number
- 5 = vbDouble - Indicates a double-precision floating-point number
- 6 = vbCurrency - Indicates a currency
- 7 = vbDate - Indicates a date
- 8 = vbString - Indicates a string
- 9 = vbObject - Indicates an automation object
- 10 = vbError - Indicates an error
- 11 = vbBoolean - Indicates a boolean
- 12 = vbVariant - Indicates a variant (used only with arrays of Variants)
- 13 = vbDataObject - Indicates a data-access object
- 17 = vbByte - Indicates a byte
- 8192 = vbArray - Indicates an array

Note: If the variable is an array VarType() returns 8192 + VarType(array_element). Example: for an array of integer VarType() will return 8192 + 2 = 8194.

### Syntax

    VarType(varname)

Parameter | Description
--- | ---
varname | Required. A variable name

### Example 1

    dim x
    x="Hello World!"
    document.write(VarType(x) & "<br />")
    x=4
    document.write(VarType(x) & "<br />")
    x=4.675
    document.write(VarType(x) & "<br />")
    x=Null
    document.write(VarType(x) & "<br />")
    x=Empty
    document.write(VarType(x) & "<br />")
    x=True
    document.write(VarType(x))

    Output:

    8
    2
    5
    1
    0
    11

Complete VBScript Reference

## Altova® MissionKit® - Integrated suite of XML tools

The Altova MissionKit is a suite of intelligent XML tools, including:

XMLSpy® – industry-leading XML editor

- Support for all XML-based technologies
- Graphical editing views, powerful debuggers, code generation, & more

MapForce® – graphical data mapping tool

- Drag-and-drop data conversion with code generation
- Support for XML, DBs, EDI, Excel® 2007, text, Web services

StyleVision® – visual stylesheet designer

- Drag-and-drop stylesheet design for XML & databases
- Output to HTML, PDF, RTF, Word 2007, & more

And more…

Try before you buy with a free fully functional 30-day trial

Download today

## Get Your Diploma!

W3Schools' Online Certification Program is the perfect solution for busy professionals who need to balance work, family, and career building.

The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.

The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.

The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.

The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.

The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).

WEB HOSTING
ASP.NET Web Hosting
$15 Domain Name Registration Save $20 / year!
Buy UK Domain Names Register Domain Names
Cheap Domain Names Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting

WEB BUILDING
Website Templates Flash Templates Website Builder Internet Business Opportunity
Custom Programming
FREE Trial or Demo Web Content Manager Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates

EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification

HOME or Top of Page |  | Printer Friendly
W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy. Copyright 1999-2009 by Refsnes Data. All Rights Reserved.