Results 1 to 4 of 4

Thread: Case

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    hi

    i am trying to dabble wth the case command here is my code

    Code:
    Select Case txtgrade.Text
        Case "A"
            lblannounce.Caption = "Perfect!"
        Case "B"
            lblannounce.Caption = "Great!"
        Case "C"
            lblannounce.Caption = "Study harder!"
        Case "D"
            lblannounce.Caption = "Get help!"
        Case "E"
           lblannounce.Caption = "Back to basics!"
        Case Else
           lblannounce.Caption = "Error in grade"
    End Select
    i have a textbox and a label all named corectley on the form

    and i keep gettig the following error on the txtgrade bit

    "invalid outside procedure"

    does anyone know why this is happening and how can i remedy it

    i only want to use the case command as i am trying to learn it
    thanks for any help


    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  2. #2
    Addicted Member Michael Woolsey's Avatar
    Join Date
    Nov 2000
    Location
    Calgary, Alberta, Canada.
    Posts
    243
    Honestly, I'm not sure what to tell you, I created a Textbox and Label, named them the same as you have, and placed your code in the Change event for the text box.

    It works properly for me...

    Code:
    Private Sub txtgrade_Change()
      Select Case txtgrade.Text
        Case "A"
            lblannounce.Caption = "Perfect!"
        Case "B"
            lblannounce.Caption = "Great!"
        Case "C"
            lblannounce.Caption = "Study harder!"
        Case "D"
            lblannounce.Caption = "Get help!"
        Case "E"
           lblannounce.Caption = "Back to basics!"
        Case Else
           lblannounce.Caption = "Error in grade"
      End Select
    End Sub
    Perhaps the problem is somewhere else?

    Just thought I would let you know.

    Michael Woolsey
    Application/Web Developer

    Visual Basic 6.0 SP5
    Active Server Pages
    Oracle 9i
    - I'm going to live forever, or die trying!

  3. #3
    Guest
    What line/word are you getting the error on?

  4. #4

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    Cheers i am soooo dumb i put it in the wrong place it wasn't in the txtgrade_change bit doh

    thanks


    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

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