Results 1 to 7 of 7

Thread: That colon thing :::::

  1. #1

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    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?

  2. #2
    Guest
    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

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    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

  4. #4
    Addicted Member LAURENS's Avatar
    Join Date
    Jan 2000
    Location
    Utrecht, the Netherlands
    Posts
    138
    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

  5. #5

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    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!

  6. #6
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    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

  7. #7
    Guest
    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
  •  



Click Here to Expand Forum to Full Width