T
Tom Shelton
Mythran said:Cor Ligthert said:Rinze,
You should try it, beside more efficient is it even quicker when you are
making a program.
Declaring global variables in the Main Section is something from the Cobol
time and very inefficient.
Cor
I used to be the same way, only dimensioning my vars at the top of the
method block...but now, after I tried it and used it...it isn't as ugly as I
thought it to be. Just dimension at the first point you need to use it. I
usually try to dimension and initialize at the same time, that way, if I
don't need the var, it's easy to track down
HTH,
Mythran
I pretty much try to dim my vars in one place - at the begining of the
scope they are used. But, I also try to limit the scope to as small as
possible. So - My code might look like (well, I mostly code C#, but
since this is a VB group
Public Sub TheBestSubEver ()
Dim anInteger As Integer
Dim aString As String
anInteger = SomeValue
For i As Integer = 0 To SomeLargeIntegerValue
Dim anIntegerInThisScope As Integer
' Do really cool loopy stuff with i and anIntegerInThisScope
Next
aString = "Hurrray, were done!"
End Sub
Anyway... That's what I do![]()