Visual Basic variables
I've noticed with VB you can declare your variables
Dim variable = value
or
Dim variable As type = value
Which one is more standard to use?
e.g. which one of the following is a better choice
Dim health = 900;
Dim health As Integer = 900;
link
Quote:
But the default changed in .NET (Option Explicit is On by default) and we were strongly encouraged to declare everything. Not only did it help the compiler catch errors so the application didn't crash at runtime, but the code ran faster because the variables were "early bound" instead of "late bound". With late binding, the compiler has to add code to figure out what a variable is before using it and that slows everything down. VB 6 was slower for the same reason.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement