hog Posted July 1, 2003 Posted July 1, 2003 Could someone explain if there is any performance advantages between the two declaration snippets below or is it just a .exe file size issue? Dim intX as Int32 Dim intY as Int32 Dim intZ as Int32 Dim intX, intY, intZ as Int32 Quote My website
Heiko Posted July 1, 2003 Posted July 1, 2003 I doubt there is a difference at all. The compiler will most probably optimize his execution time anyway. I recommend the upper style, though. Makes it easier to read, comment and edit. Quote .nerd
*Experts* Volte Posted July 1, 2003 *Experts* Posted July 1, 2003 I use the upper method for most things, because it allows you to initialize the variable, and use the 'New' keyword to initialize the object. Quote
Martin Posted July 1, 2003 Posted July 1, 2003 I would tend to use the upper method also, makes it easier to check data types of declared objects and generally looks cleaner to read. Quote
Mothra Posted July 1, 2003 Posted July 1, 2003 Also, (not sure if this carried over to .NET but) I think in 6.0, the lower style would only declare the specific type to the last var in the list. e.g. Dim var1, var2, var3 As Integer this would end up with var1 & var2 as variable type Variant and only var3 would actually be an Integer. As I'm typing this, I'm having doubts as to weather or not this was the case, however, I seem to recall this hapening to me once or twice before I figured it out. If I'm just way out in left field (as usual...) just ignor me. I don't get much sleep these days! Quote Being smarter than you look is always better than looking smarter than you are.
*Gurus* Derek Stone Posted July 2, 2003 *Gurus* Posted July 2, 2003 That is no longer the case under .NET, Mothra. Variables declared in a list do not default to Object; they are declared as is specified by the As <Type> keywords. Quote Posting Guidelines
Mothra Posted July 2, 2003 Posted July 2, 2003 Good to know, thanks Derek. Although, I'll be using the one line per declaration also, if for nothing more than out of habit. And I do find it easier to read. Quote Being smarter than you look is always better than looking smarter than you are.
ThePentiumGuy Posted July 2, 2003 Posted July 2, 2003 Could someone explain if there is any performance advantages between the two declaration snippets below or is it just a .exe file size issue? Dim intX as Int32 Dim intY as Int32 Dim intZ as Int32 Dim intX, intY, intZ as Int32 heh, this first way is easier to read, thes econd way takes up less space.. my mario game for instance, as about like 30 variables( i think) so i try to use the lower method Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
*Experts* Volte Posted July 2, 2003 *Experts* Posted July 2, 2003 A good way to conserv space (is with regions):#Region " Variables " Dim blah As Blah ' ... ' ... ' ... #End RegionThen you can simple expand and contract the region. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.