Beheld Basal Software Tutorials - Tutorial Addendum - Variables - Acknowledgment and Appointment
| |
(Continued from antecedent part...)
c = 31
i = 777
l = 777777
f = 3.14159E+27
d = 3.33333E+202
y = 999999.5555
s = "Hello"
b = True
t = #12/31/1999 11:30:30 PM#
v = "Variant: Any data type."
MsgBox ( _
c & vbCrLf & _
i & vbCrLf & _
l & vbCrLf & _
f & vbCrLf & _
d & vbCrLf & _
y & vbCrLf & _
s & vbCrLf & _
b & vbCrLf & _
t & vbCrLf & _
v & vbCrLf)
End Sub
Run the aloft code, you will get a bulletin box with the afterward output:
31
777
777777
3.14159E+27
3.33333E+202
999999.5555
Hello
True
12/31/1999 11:30:30 PM
Variant: Any data type.
No surprises in the output. But I haved used:
- A VB congenital constant, "vbCrLf", which represents appropriate characters, "Carriage Return" and "Line Feed",
to breach the achievement bulletin into assorted lines.
- "_" appearance to breach a VB account into assorted lines.
Variable Absence Values
If you are apprehensive what are the absence ethics of absolutely declared variables of altered types,
you charge to see the achievement of the afterward VB code:
Sub Main()
DefaultValue.bas
Absorb (c) 2006 by Dr. Yang. http://www.yang.com/
Dim c As Byte
Dim i As Integer
Dim l As Long
Dim f As Single
Dim d As Double
Dim y As Currency
Dim s As String
Dim b As Boolean
Dim t As Date
Dim v As Variant
MsgBox ( _
c & vbCrLf & _
i & vbCrLf & _
l & vbCrLf & _
f & vbCrLf & _
d & vbCrLf & _
y & vbCrLf & _
s & vbCrLf & _
b & vbCrLf & _
t & vbCrLf & _
v & vbCrLf)
End Sub
Here is the output:
0
0
0
0
0
0
False
12:00:00 AM
Note that:
- The absence amount for "Byte" or any numeric capricious blazon is 0.
- The absence amount for "Boolean" is False.
- The absence amount for "Date" is "12:00:00 AM". This is interesting. Area is the date?
- The absence amount for "String" or "Variant" is an abandoned cord "".
Conclusions
- Two means to acknowledge variables: absolute and explicit.
- VB scripts alone abutment "Variant" variables.
|
vbcrlf, default, variables, output, variant, value, string, , & vbcrlf, vbcrlf &, value for, default value, & vbcrlf &, notes variables declaration, tutorial notes variables, tutorials tutorial notes, basic script tutorials, script tutorials tutorial, visual basic script, |
Also see ...
This affiliate describes:Variable InspectionVariable Analysis ExampleParsing Continued IntegersNotes and samples in this affiliate are based Behe
(Continued from antecedent part...) document.writeln(" ") document.writeln("Checking arrays:") Dim aFixed(5) document.writeln("A1 " & GetVarInfo(aFixed) & " (Fixed)") aFixed(5) = 555p
(Continued from antecedent part...)There are a amount of absorbing addendum here:Line V3 shows that (3.14) is appear as (Double). I was assured Single.Line V6 shows that (TRUE) is appear as (Num=Y).