|
-
Jul 17th, 2000, 06:48 AM
#1
Thread Starter
Fanatic Member
I've seen the colon thing used in code, apparently to allow one line of code to sit behind another, eg:
Code:
Msgbox "Nice one Cyril" : Msgbox "Bit Corny though..."
Sortafing.
I can't find any mention of this fab thing in the "help" screens, can anyone shed any light?
-
Jul 17th, 2000, 06:55 AM
#2
well this:
Code:
Msgbox "Nice one Cyril" : Msgbox "Bit Corny though..."
is the equiv of:
Code:
Msgbox "Nice one Cyril"
Msgbox "Bit Corny though..."
Just lets you put related stuff on the same line.
I always use it for short If statements, like
Code:
If x = 1 Then MsgBox "AHH!!!": Exit Sub
Sunny
-
Jul 17th, 2000, 07:02 AM
#3
_______
represents end of the line/newline
Code:
Private Sub Form_Load()
MsgBox "Hello": Dim x As String: x = "MyMy What a thing.": MsgBox x: Unload Me
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 17th, 2000, 07:59 AM
#4
Addicted Member
I think it's provided as a way to make code difficult to read. VB is a bit lacking there compared to C. Don't get me wrong, C is not necessarily difficult to read but it has a lot of possibilities there.
In short, I don't like it.
Regards,
Laurens
Using VB5 Enterprise edition SP3
VB6 Enterprise edition SP5
-
Jul 17th, 2000, 08:33 AM
#5
Thread Starter
Fanatic Member
Thanks awfully chaps. I think I'll go write myself a one line program. And then ask you all to debug it for me har har har!
-
Jul 17th, 2000, 10:45 PM
#6
Lively Member
Actually, the :, along with many other oddities of VB are remnants of the original BASIC language (such as the 'Let' statement). I remember when I first started programming in GW-BASIC. GW-BASIC didn't have subs, functions, or even named labels - you had 'GOTO' and 'GOSUB', and every line had a line number. These were the days of 'DEF FN', the days of 'FIELD' for random-access data. Well, along with these many other items, you only had single-line IF...THEN...ELSE statements. Therefore, the only way you could do more than one command in an IF statement was like this:
IF blah THEN x: y: z ELSE a: b: c
It comes in handy sometimes (mostly for this purpose); thus, it remains with us today.
- Steve
Real programmers use COPY CON PROGRAM.EXE
-
Jul 17th, 2000, 11:08 PM
#7
The : in VB is just to make code shorter on your screen.
This:
Code:
somethingfornothing = Good
somethingforfree = Good
somethingforaprice = Bad
somethingnotfree = Bad
Can be turned into this:
Code:
somethingfornothing = Good: somethingforfree = Good:somethingforaprice = Bad:somethingnotfree = Bad
To make it look a bit shorter .
Dunno why VB had that.
Guess we'll never find out.
Unless someone wants to email Microsoft and ask them .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|