On a side note... (Just FYI)
Code:
Dim [b]x, y,[/b] intLineCount As Integer
Only declares intLineCount as an integer...
x & y are both declared as Variants, and is the same as not declaring them at all...
By default, the above statment is interpreted as:
Code:
Dim [b]x As Variant, y As Variant,[/b] intLineCount As Integer
To test this...
You cannot assign a string to an integer...
So, with a simple textBox (Text1) and a Button (Command1) try this code:
Code:
Private Sub Command1_Click()
Dim x, y As Integer
x = "hello"
Text1 = x
End Sub
where this will raise an error:
Code:
Private Sub Command1_Click()
Dim x, y As Integer
[COLOR=black yellow] y = "hello"[/color]
Text1 = y
End Sub
To Assign the types correctly, you must specify each type...
Code:
Dim x [b]As Integer[/b], y [b]As Integer[/b], intLineCount As Integer
ON THE OTHER HAND...
You can use
DefInt A-Z to set the default type to Integer, then you only have to say:
Code:
[b]DefInt A-Z[/b]
Sub Blah()
Dim X, Y
...
End Sub
which is the equivalent of:
Code:
Sub Blah()
Dim X [b]As Integer[/b], Y [b]As Integer[/b]
...
End Sub
variations of this include:
DefBool letterrange[, letterrange] . . .
DefByte letterrange[, letterrange] . . .
DefInt letterrange[, letterrange] . . .
DefLng letterrange[, letterrange] . . .
DefCur letterrange[, letterrange] . . .
DefSng letterrange[, letterrange] . . .
DefDbl letterrange[, letterrange] . . .
DefDec letterrange[, letterrange] . . .
DefDate letterrange[, letterrange] . . .
DefStr letterrange[, letterrange] . . .
DefObj letterrange[, letterrange] . . .
DefVar letterrange[, letterrange] . . .
the letterrange is a range of letters that assign the given type to any variable who's first letter is included in the range...
A-Z includes ALL variables...
You can specify specific ranges to different defaults, and multiple ranges to the same default, such as:
Code:
DefStr S-T
DefSng U-V
DefDbl W
DefInt A-C, I, X-Z
See
Deftype Statements in help for more info...
In previous versions of Basic (such as QuickBasic aka QB) DefInt A-Z had to be placed immediately before any procudure they were to be applied to...
In VB, you just place them in the Declarations area...
As you might have guessed, DefVar A-Z is VB's default...
(*History: DefSng A-Z was QB's default)
Just thought you might want to know...
This might save some headaches in the future ;-)
Visit My Site
PROGRAMMER:
Red-eyed, mumbling mammal capable of conversing with inanimate objects.