|
-
Visual Basic HELP
Hey guys, I need your help. I am a newbie in VB and needa know how to use the "CASE" statements properly....Also, a few easy examples would be appreciated!
Thank you.
-
umm, not trying to state the obvious but have you tried looking at the help files ? They have an example for pretty much every command, I know there is one for the CASE command.
------------------
/At least I have a positive attitude about my destructive habits/
/At least I have a positive attitude about my destructive habits/
-
Just to save you time here's the VB example.
Dim Number
Number = 8 ' Initialize variable.
Select Case Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5.
Debug.Print "Between 1 and 5"
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8 ' Number between 6 and 8.
Debug.Print "Between 6 and 8"
Case Is > 8 And Number < 11 ' Number is 9 or 10.
Debug.Print "Greater than 8"
Case Else ' Other values.
Debug.Print "Not between 1 and 10"
End Select
/At least I have a positive attitude about my destructive habits/
-
Oh, I know how now....Thanks......
BTW, I don't have MSDN but I am gonna get a VB book this weekend.
-
Anyone know of a good visual basic site?
I'm taking a class in it right now. I'm on reading a file fixing the words and making it all initial caps for every word and deleting non chars. Having a little trouble.
-
http://www.dcs.napier.ac.uk/hci/VB50/home.html
Originally posted by Freedom65:
Hey guys, I need your help. I am a newbie in VB and needa know how to use the "CASE" statements properly....Also, a few easy examples would be appreciated!
Thank you.
-
Hi:
If you plan to use VB for a longer period of time I'd recommend a book. For instance "Mastering VB" - Sybex.
I've been using it for two years...
Krixk
-
The case statement is a test condition that is the opposit of the if statement.
Lets say we have a text box on a form named txtName.Text
and you wanted to test for a couple of numbers lets say 666 and 1790.
The syntax would be
Select Case txtName.Text
Case 666
msgbox"You have the my favorite number"
Case 1790
msgbox"You have the right number"
Case Else
msgbox"Sorry try again"
End Select
''-------------------------------------------
Select Case txtName.Text(the condition that will be tected)
Case 666
msgbox"You have the my favorite number"(If the text inside "txtName.Text" is = to 666 then the program will give you a message box that will tell you that 666 is my favorite number.)
Case 1790
msgbox"You have the right number"
If the value of txtName.Text =1790 then
then the program will give you a message box that will tell you that 1790 You have the right number)
If neither 1790 or 666 is entered the program will give
msgbox"Sorry try again"
End Select( ends the Case Statement)
-
http://www.planetsourcecode.com
Originally posted by Schmitty:
Anyone know of a good visual basic site?
I'm taking a class in it right now. I'm on reading a file fixing the words and making it all initial caps for every word and deleting non chars. Having a little trouble.
-
Another example in VBScript tough:
users.pandora.be/caey/
look at the source, it is a multimedia sequencer and the selct case stuff is around the 1/3 of the page
-
Goblin Shark
If you guys are doing this for a living, subscribe to TechNet.
It is, at times, my right hand...
------------------
Happy Halloween, Ladies!
If I couldn't type drunk, I'd still be Expensive Sushi.
-
here r some good vb info sites:
www.vbsquare.com www.vbhelp.com/ubbcgi/ultimate.cgi www.vbcode.com
cuinl.tripod.com/tips-and-tricks.htm
also in IRC
server: forums.vbchat.com
channel: #vbchat
"Those who do not know their opponent's arguements do no completely understand their own."
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
|
|