Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
unknown sign of VB Posted by ranainnet on 4 Oct 2005 at 12:58 PM
Hie there fellows. Thanks for replying my previous messages. But I have another problem now. Hope to get help now to.

The problem is, I downloaded some example VB programs form the net and while looking at the codes of one program I have found a new sign in the code. I have tried to find out the meaning of the sign in the MSDN but could not findout any meaning.

The sign is " : " (colon). I have checked that the : sign was not a part of comment but a part of code.

Could anybody please tell me what does it mean and what is its function.
_____________________________________________________________________________
Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->
Report
Re: unknown sign of VB Posted by infidel on 5 Oct 2005 at 7:48 AM
: Hie there fellows. Thanks for replying my previous messages. But I have another problem now. Hope to get help now to.
:
: The problem is, I downloaded some example VB programs form the net and while looking at the codes of one program I have found a new sign in the code. I have tried to find out the meaning of the sign in the MSDN but could not findout any meaning.
:
: The sign is " : " (colon). I have checked that the : sign was not a part of comment but a part of code.
:
: Could anybody please tell me what does it mean and what is its function.

Most of the time it indicates a "label", which is just a point that GoTo can jump to. Yes, GoTo is a Bad Thing (tm) when misused, but VB doesn't provide for structured error handling or Return statements like .NET does, so sometimes the only way to accomplish things cleanly is through judicial use of GoTo.

Public Sub Foo()

    On Error GoTo FooError

    'do stuff

    If SomeExitCondition = True Then GoTo FooExit

    'do other stuff

FooExit:
    Exit Sub

FooError:
    MsgBox "FOO!"

End Sub


In some cases it's also a line-separator, meaning you can combine two statements on one line in certain circumstances:

Public Sub Foo()

    Dim bar As String: bar = "foo"

End Sub



infidel

$ select * from users where clue > 0
no rows returned


Report
Re: unknown sign of VB Posted by ranainnet on 5 Oct 2005 at 11:32 AM
: : Hie there fellows. Thanks for replying my previous messages. But I have another problem now. Hope to get help now to.
: :
: : The problem is, I downloaded some example VB programs form the net and while looking at the codes of one program I have found a new sign in the code. I have tried to find out the meaning of the sign in the MSDN but could not findout any meaning.
: :
: : The sign is " : " (colon). I have checked that the : sign was not a part of comment but a part of code.
: :
: : Could anybody please tell me what does it mean and what is its function.
:
: Most of the time it indicates a "label", which is just a point that GoTo can jump to. Yes, GoTo is a Bad Thing (tm) when misused, but VB doesn't provide for structured error handling or Return statements like .NET does, so sometimes the only way to accomplish things cleanly is through judicial use of GoTo.
:
:
: Public Sub Foo()
: 
:     On Error GoTo FooError
: 
:     'do stuff
: 
:     If SomeExitCondition = True Then GoTo FooExit
: 
:     'do other stuff
: 
: FooExit:
:     Exit Sub
: 
: FooError:
:     MsgBox "FOO!"
: 
: End Sub
: 

:
: In some cases it's also a line-separator, meaning you can combine two statements on one line in certain circumstances:
:
:
: Public Sub Foo()
: 
:     Dim bar As String: bar = "foo"
: 
: End Sub
: 

:
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:
Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels. For clearity I am sending some segments of the code below------

If CurMonNo% = 0 Then Universe.TotMonsters = Universe.TotMonsters + 1: CurMonNo% = Universe.TotMonsters
____________________________________________________________________________________
For X% = 0 To 100
Map(X%, 0, 1).icon = 4: Map(X%, 0, 1).Blocked = True
Map(X%, 1, 1).icon = 4: Map(X%, 1, 1).Blocked = True
Map(X%, 99, 1).icon = 4: Map(X%, 99, 1).Blocked = True
Map(X%, 100, 1).icon = 4: Map(X%, 100, 1).Blocked = True
Next X%

____________________________________________________________________________________
For Y% = 0 To 100
Map(0, Y%, 1).icon = 4: Map(0, Y%, 1).Blocked = True
Map(1, Y%, 1).icon = 4: Map(1, Y%, 1).Blocked = True
Map(99, Y%, 1).icon = 4: Map(99, Y%, 1).Blocked = True
Map(100, Y%, 1).icon = 4: Map(100, Y%, 1).Blocked = True
Next Y%

____________________________________________________________________________________
For X% = 2 To 98
If Rnd > 0.5 Then Map(X%, 2, 1).icon = 4: Map(X%, 2, 1).Blocked = True
If Rnd > 0.5 Then Map(X%, 3, 1).icon = 4: Map(X%, 3, 1).Blocked = True
If Rnd > 0.5 Then Map(X%, 97, 1).icon = 4: Map(X%, 97, 1).Blocked = True
If Rnd > 0.5 Then Map(X%, 98, 1).icon = 4: Map(X%, 98, 1).Blocked = True
Next X%
For Y% = 2 To 98
If Rnd > 0.5 Then Map(2, Y%, 1).icon = 4: Map(2, Y%, 1).Blocked = True
If Rnd > 0.5 Then Map(3, Y%, 1).icon = 4: Map(3, Y%, 1).Blocked = True
If Rnd > 0.5 Then Map(97, Y%, 1).icon = 4: Map(97, Y%, 1).Blocked = True
If Rnd > 0.5 Then Map(98, Y%, 1).icon = 4: Map(98, Y%, 1).Blocked = True
Next Y%

____________________________________________________________________________________
For X1% = 1 To 100
X% = Int(Rnd * 90) + 5
Y% = Int(Rnd * 90) + 5
Map(X%, Y%, 1).icon = 5: Map(X%, Y%, 1).Blocked = True
Next X1%
____________________________________________________________________________________

The use of : sign in the above statements are certainly not part of label. So any farther information will be highly appreciated. Please do reply.
_____________________________________________________________________________
Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

Report
Re: unknown sign of VB Posted by aatkbd on 5 Oct 2005 at 12:47 PM
: Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels. For clearity I am sending some segments of the code below------
:
: If CurMonNo% = 0 Then Universe.TotMonsters = Universe.TotMonsters + 1: CurMonNo% = Universe.TotMonsters
: ____________________________________________________________________________________
: For X% = 0 To 100
: Map(X%, 0, 1).icon = 4: Map(X%, 0, 1).Blocked = True
: Map(X%, 1, 1).icon = 4: Map(X%, 1, 1).Blocked = True
: Map(X%, 99, 1).icon = 4: Map(X%, 99, 1).Blocked = True
: Map(X%, 100, 1).icon = 4: Map(X%, 100, 1).Blocked = True
: Next X%
:
: The use of : sign in the above statements are certainly not part of label. So any farther information will be highly appreciated. Please do reply.
: _____________________________________________________________________________
: Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->
:
:

here is an excerpt from the VB help files.


Remarks

You can use the single-line form (first syntax) for short, simple tests. However, the block form (second syntax) provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug.

Note With the single-line form, it is possible to have multiple statements executed as the result of an If...Then decision. All statements must be on the same line and separated by colons, as in the following statement:

If A > 10 Then A = A + 1 : B = B + A : C = C + B

Report
Re: unknown sign of VB Posted by ranainnet on 5 Oct 2005 at 2:34 PM
: : Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels. For clearity I am sending some segments of the code below------
: :
: : If CurMonNo% = 0 Then Universe.TotMonsters = Universe.TotMonsters + 1: CurMonNo% = Universe.TotMonsters
: : ____________________________________________________________________________________
: : For X% = 0 To 100
: : Map(X%, 0, 1).icon = 4: Map(X%, 0, 1).Blocked = True
: : Map(X%, 1, 1).icon = 4: Map(X%, 1, 1).Blocked = True
: : Map(X%, 99, 1).icon = 4: Map(X%, 99, 1).Blocked = True
: : Map(X%, 100, 1).icon = 4: Map(X%, 100, 1).Blocked = True
: : Next X%
: :
: : The use of : sign in the above statements are certainly not part of label. So any farther information will be highly appreciated. Please do reply.
: : _____________________________________________________________________________
: : Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->
: :
: :
:
: here is an excerpt from the VB help files.
:
:
: Remarks
:
: You can use the single-line form (first syntax) for short, simple tests. However, the block form (second syntax) provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug.
:
: Note With the single-line form, it is possible to have multiple statements executed as the result of an If...Then decision. All statements must be on the same line and separated by colons, as in the following statement:
:
: If A > 10 Then A = A + 1 : B = B + A : C = C + B
:

:
Thanks a lot for the help. I was also guessing something like this. But I became confused while I had put :(colon) sign in the index search of MSDN and got nothing related to VB there.

By the by I got my answer and lots of lots of thanks to everybody for helping me.
_____________________________________________________________________________
Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

Report
Re: unknown sign of VB Posted by infidel on 5 Oct 2005 at 3:22 PM
You asked:

: : : Could anybody please tell me what does it mean and what is its function.

I said:

: : Most of the time it indicates a "label" ...

I also said:

: : In some cases it's also a line-separator, meaning you can combine two statements on one line in certain circumstances ...

Then you said:

: Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels ...

Please try to pay attention


infidel

$ select * from users where clue > 0
no rows returned


Report
Re: unknown sign of VB Posted by lionb on 6 Oct 2005 at 4:20 AM
: You asked:
:
: : : : Could anybody please tell me what does it mean and what is its function.
:
: I said:
:
: : : Most of the time it indicates a "label" ...
:
: I also said:
:
: : : In some cases it's also a line-separator, meaning you can combine two statements on one line in certain circumstances ...
:
: Then you said:
:
: : Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels ...
:
: Please try to pay attention
:
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:
ranainnet,

In future, if you will have problem with code, please, post that portion of code. It will be easier for people from PH to understand what your problem is and explain to you how to fix it.
Report
Re: unknown sign of VB Posted by ranainnet on 6 Oct 2005 at 10:25 AM
This message was edited by ranainnet at 2005-10-6 11:0:35

: : You asked:
: :
: : : : : Could anybody please tell me what does it mean and what is its function.
: :
: : I said:
: :
: : : : Most of the time it indicates a "label" ...
: :
: : I also said:
: :
: : : : In some cases it's also a line-separator, meaning you can combine two statements on one line in certain circumstances ...
: :
: : Then you said:
: :
: : : Thanks for your reply. Now I remember the use of :(colon) sign in labels. But yet my problem is not fixed. Because I have checked the codes again and the statements which are using the : sign don't seem to be part of labels ...
: :
: : Please try to pay attention
: :
: :
: : infidel
: :
: :
: : $ select * from users where clue > 0
: : no rows returned
: : 

: :
: :
: ranainnet,
:
: In future, if you will have problem with code, please, post that portion of code. It will be easier for people from PH to understand what your problem is and explain to you how to fix it.
:
Thanks for ur suggestions. And yes u r right "infidel", I should give more concentration while reading replys. Please don't mind and forgive me for my carelessness. I really do appreciate all of yours' effort. Hope you fellows could forgive me. Please don't mind. I guess that I was a bit excited while remembered about the use of : as a part of label and thats the reason behind overlooking the next part. Thanks again for the advice.
_____________________________________________________________________________
Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.