Subtype | Note: If the variable is not declared, the default data type it would be assigned to is 'Variant' and the default value of Variant is empty/null. Data types: Description |
|---|---|
| Empty | Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables. |
| Null | Variant intentionally contains no valid data. |
| Boolean | Contains either True or False. |
| Byte | Contains integer in the range 0 to 255. |
| Integer | Contains integer in the range -32,768 to 32,767. |
| Currency | -922,337,203,685,477.5808 to 922,337,203,685,477.5807. |
| Long | Contains integer in the range -2,147,483,648 to 2,147,483,647. |
| Single | Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. |
| Double | Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. |
| Date (Time) | Contains a number that represents a date between January 1, 100 to December 31, 9999. |
| String | Contains a variable-length string that can be up to approximately 2 billion characters in length. |
| Object | Contains an object. |
| Error | Contains an error number. |
Type Declaration Characters: Are the symbols that represents data types.
| Identifier type character | Data type | Example |
|---|---|---|
| % | Integer | Dim L% |
| & | Long | Dim M& |
| @ | Decimal | Const W@ = 37.5 |
| ! | Single | Dim Q! |
| # | Double | Dim X# |
Note: Dim x% is same as Dim x as Integer.
User Defined types:
Combine variables and fundamental data types to create user-defined data types.
Use Type and End Type statements in the declaration section to create a user defined data types.
Combine variables and fundamental data types to create user-defined data types.
Use Type and End Type statements in the declaration section to create a user defined data types.
In the above example EmpDet is user defined data type that has Byte and Integer variables.
And in the below screen, Student type is used while declaring st1 variable.?????
Implicit and Explicit Declaration of variable:
1. If the variable is declared using Dim it means, it is explicit declaration here you have to mention the data type of the variable that you using
2. Implicit declaration is when you use the variable without declaring it, but the type of variable depends on the value assigned to it.
Scope of the variables:
Public and Private.
Static Variables??
Static variables are used to retain the value of the variable even after the procedure has finished the execution.
syntax: Static <var name> as <data type>
Loop structures in VB include:
1. For .... Next
2. Do...While
3. While .... Wend??
4. With ....End With ??
In the above example for Student User defined type, how st1.name is used???? throw some light on the same....
ReplyDelete