Author | Message | Time |
---|---|---|
Imperceptus | Is there any speed advantage to using a : in your code instead of writing code on the next line? | June 3, 2004, 2:33 PM |
Grok | [quote author=Imperceptus link=board=31;threadid=7087;start=0#msg63440 date=1086273210] Is there any speed advantage to using a : in your code instead of writing code on the next line? [/quote] No. | June 3, 2004, 5:03 PM |
Dyndrilliac | If your referring to things like:[code]If Blah = True Then: Exit Sub[/code]Then no. I always felt it was good programming style to do:[code]If Blah = True Then Exit Sub End If[/code] It's my experience that not only is the code easier to read but also more modular. Very annoying when people write their code without ever knowing the tab button exists. | June 3, 2004, 7:01 PM |
CrAz3D | Why not [code]If Blah=true then exit sub[/code] It works too?... | June 3, 2004, 7:20 PM |
Lobo.id | You could use it with select case. If your only wanting to call one thing. [code] Select Case this Case 1: dosomething End Select [/code] | June 3, 2004, 7:22 PM |
Stealth | The compiler will optimize your code when it compiles it either way. Using excessive :'s to break up lines of code will just confuse you -- whitespace is valuable, and in VB, whitespace is cheap -- use it often. | June 3, 2004, 9:29 PM |
Tuberload | I am not a VB expert but in Java white space is ignored on compile time. It is essentially allowed so you can format your code in whatever silly way you want so, as Stealth said, your code is easier to understand. Visual Basic seems to force you to format your code following there standard though (I hate having to use the underscore for multiple line operations). | June 3, 2004, 10:04 PM |
Adron | And I like to use : in a few instances. I use it to assign a value and then exit sub/function on the same line as an if statement. Typically to set an error status, corresponding to a C++ "return X;" which already does both the assignment and the exit. I use it for patterns, where I find it easier to read the pattern if each instance is a line in a colon-separated table: Select Case var Case 1: msg = "Please do": answer = "OK" Case 2: msg = "Will you?": answer = "Yes|No" Case 3: msg = "Error!": answer = "Abort|Retry|Ignore" End Select | June 3, 2004, 11:12 PM |
Stealth | [quote author=Tuberload link=board=31;threadid=7087;start=0#msg63495 date=1086300290] Visual Basic seems to force you to format your code following there standard though (I hate having to use the underscore for multiple line operations). [/quote] Yes -- between, before and after lines of code whitespace is cheap. The lines themselves must adhere to the IDE's standard. :) | June 4, 2004, 12:26 AM |
Spht | [quote author=CrAz3D link=board=31;threadid=7087;start=0#msg63476 date=1086290422] Why not [code]If Blah=true then exit sub[/code] It works too?... [/quote] And why not [code]If Blah Then Exit Sub[/code] Because it's personal preference! | June 4, 2004, 12:30 AM |
Myndfyr | [quote author=Adron link=board=31;threadid=7087;start=0#msg63504 date=1086304378] I use it for patterns, where I find it easier to read the pattern if each instance is a line in a colon-separated table: Select Case var Case 1: msg = "Please do": answer = "OK" Case 2: msg = "Will you?": answer = "Yes|No" Case 3: msg = "Error!": answer = "Abort|Retry|Ignore" End Select [/quote] Of course, what Adron really meant was: [code] Case 3: msg = "Feature!": answer = "Abort|Retry|Ignore" [/code] ;) | June 4, 2004, 12:49 AM |
SPY-3 | only good thing about using a : is it doesnt have as many lines in your code for things like file opens its prob easier to do this open Blah for input as #1: input#1, bleh:close #1:text1.text = bleh then you dont waste as much space. so only nice thing about : is not wasting lines as much | August 27, 2004, 1:21 PM |