visual basic data type

' For VBA / VB / Visual Basic only

'EXAMPLE
  Dim sStringVar as String
  sStringVar = "What data-type am I being seen as?"
  MsgBox(VarType(sStringVar)) ' This will give an output of: 8

'SYNTAX
'	VarType(<variable-that-you-want-to-check-the-data-type-of>)

'NOTE: the date types are as follows:
+-------+----------------------+------------------------------------------------------------------------+
| VALUE |     CONSTANT         | DESCRIPTION                                                            |
+-------+----------------------+------------------------------------------------------------------------+
|   0   |   vbEmpty            | Empty (uninitialized)                                                  |
|   1   |   vbNull             | Null (no valid data)                                                   |
|   2   |   vbInteger          | Integer                                                                |
|   3   |   vbLong             | Long integer                                                           |
|   4   |   vbSingle           | Single-precision floating-point number                                 |
|   5   |   vbDouble           | Double-precision floating-point number                                 |
|   6   |   vbCurrency         | Currency value                                                         |
|   7   |   vbDate             | Date value                                                             |
|   8   |   vbString           | String                                                                 |
|   9   |   vbObject           | Object                                                                 |
|  10   |   vbError            | Error value                                                            |
|  11   |   vbBoolean          | Boolean value                                                          |
|  12   |   vbVariant          | Variant (used only with arrays of variants)                            |
|  13   |   vbDataObject       | A data access object                                                   |
|  14   |   vbDecimal          | Decimal value                                                          |
|  17   |   vbByte             | Byte value                                                             |
|  20   |   vbLongLong         | LongLong integer (valid on 64-bit platforms only)                      |
|  36   |   vbUserDefinedType  | Variants that contain user-defined types                               |
| 8192  |   vbArray            | Array (always added to another constant when returned by this function)|
+-------+----------------------+------------------------------------------------------------------------+

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source