Visual Basic HELP

Sharky Forums


Results 1 to 12 of 12

Thread: Visual Basic HELP

  1. #1

    Arrow 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.

  2. #2
    Goldfish
    Join Date
    Sep 2000
    Location
    Taunton, Somerset, UK
    Posts
    64

    Post

    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/

  3. #3
    Goldfish
    Join Date
    Sep 2000
    Location
    Taunton, Somerset, UK
    Posts
    64

    Post

    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/

  4. #4

    Talking

    Oh, I know how now....Thanks......


    BTW, I don't have MSDN but I am gonna get a VB book this weekend.

  5. #5
    Tiger Shark
    Join Date
    Oct 2000
    Posts
    728

    Post

    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.

  6. #6
    Expensive Sushi
    Join Date
    Oct 2000
    Location
    sanford, fl, USA
    Posts
    46

    Post

    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.

  7. #7
    Expensive Sushi
    Join Date
    Oct 2000
    Posts
    11

    Red face

    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

  8. #8
    Hammerhead Shark
    Join Date
    Sep 2000
    Location
    Rochester, NY USA
    Posts
    1,033

    Post

    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)


    Never forget Sept. 11, 2001.

    Enigma & Code-Breaker

  9. #9
    Expensive Sushi
    Join Date
    Oct 2000
    Location
    USA
    Posts
    28

    Post

    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.

  10. #10
    Expensive Sushi
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    7

    Post

    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

  11. #11
    Goblin Shark BoogyMan's Avatar
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    8,316

    Cool

    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.

  12. #12
    Expensive Sushi
    Join Date
    Nov 2000
    Location
    Brooklyn NY
    Posts
    15

    Post

    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
  •