Reputation: 21
When i define an initialize a variable i get the compile time error as "Expected:End of statement". The code is :
Dim i as integer=1
Upvotes: 1
Views: 7166
Reputation: 2213
You cannot assign a value to a variable you are declaring in VB6, UNLESS it is a constant
' BAD
Dim i as Integer = 1
' GOOD
Dim i As Integer
Const i As Integer = 1
Upvotes: 2
Reputation: 27342
The VB6 compiler does not let you declare and initialise a variable in one line (like you can in VB.NET).
So you have to declare it on one line and initialise it on another:
Dim i As Integer
i = 1
If you want to have both statement on the same line you can use a colon:
Dim i As Integer : i = 1
But you can only do this inside a procedure and not in a module, form or class declaration
Upvotes: 6
Reputation: 18757
dim i as integer
i=1
You need to split declaring a variable and assigning its value.
Upvotes: 3