• Welcome to Valhalla Legends Archive.
 

Help with :

Started by Imperceptus, June 03, 2004, 09:33 AM

Previous topic - Next topic

Imperceptus

Is there any speed advantage to using a : in your code instead of writing code on the next line?
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

Grok

Quote from: Imperceptus on June 03, 2004, 09:33 AM
Is there any speed advantage to using a : in your code instead of writing code on the next line?

No.

Dyndrilliac

If your referring to things like:If Blah = True Then: Exit SubThen no. I always felt it was good programming style to do:If Blah = True Then
   Exit Sub
End If


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.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

CrAz3D

Why not
If Blah=true then exit sub
It works too?...
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Lobo

#4
You could use it with select case.  If your only wanting to call one thing.

Select Case this
       Case 1: dosomething
End Select
Look it's a signature.

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.
- Stealth
Author of StealthBot

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).
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

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

Stealth

Quote from: Tuberload on June 03, 2004, 05:04 PM
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).

Yes -- between, before and after lines of code whitespace is cheap. The lines themselves must adhere to the IDE's standard. :)
- Stealth
Author of StealthBot

Spht

Quote from: CrAz3D on June 03, 2004, 02:20 PM
Why not
If Blah=true then exit sub
It works too?...

And why not

If Blah Then Exit Sub

Because it's personal preference!

MyndFyre

Quote from: Adron on June 03, 2004, 06:12 PM
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

Of course, what Adron really meant was:

  Case 3: msg = "Feature!": answer = "Abort|Retry|Ignore"


;)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

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