Results 1 to 7 of 7

Thread: Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    20

    Help

    I am doin a school project and i am having problems with a code. It does not seem work.

    Code:
    Private Sub Command1_Click()
    If Text1 >= 86 Then
        Label2.Caption = "Nicely done!" And Image1.Visible = True
        ElseIf Text1 < 86 >= 73 Then
            Label2.Caption = "Good Job!" And Image2.Visible = True
        ElseIf Text1 < 73 >= 65 Then
            Label2.Caption = "Right on!" And Image3.Visible = True And Image5.Visible = True
        ElseIf Text1 < 65 >= 60 Then
            Label2.Caption = " Not bad" And Image3.Visible = True
        ElseIf Text1 < 60 >= 49 Then
            Label2.Caption = "You got to try harder" And Image3.Visible = True And Image6.Visible = True
        ElseIf Text1 < 49 Then
            Label2.Caption = "Need more studying" And Image4.Visible = True
    End If
    End Sub
    
    Private Sub Command2_Click()
    Label2.Caption = " "
    Text1.Text = " "
    End Sub
    
    Private Sub Form_Load()
    Image1.Visible = False
    Image2.Visible = False
    Image3.Visible = False
    Image4.Visible = False
    Image5.Visible = False
    Image6.Visible = False
    End Sub
    
    Private Sub Quit_Click()
    End
    End Sub

  2. #2
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Help

    Welcome to VBF

    Try changing your code as follows
    Code:
             Label2.Caption = "Nicely done!" 
             Image1.Visible = True
        ElseIf Text1 < 86 >= 73 Then
            Label2.Caption = "Good Job!" 
            Image2.Visible = True
        ElseIf .....
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help

    I would do something like
    Code:
    Select Case Val(Text1.Text)
       Case Is > 86
             Label2.Caption = "Nicely done!" And Image1.Visible = True
       Case 73 To 86
            Label2.Caption = "Good Job!" And Image2.Visible = True
       Case 65 To 72
            Label2.Caption = "Right on!" And Image3.Visible = True And Image5.Visible = True
       Case 60 To 64
            Label2.Caption = " Not bad" And Image3.Visible = True
      Case 49 To 59
            Label2.Caption = "You got to try harder" And Image3.Visible = True And Image6.Visible = True
     Case Is < 49
            Label2.Caption = "Need more studying" And Image4.Visible = True
    End Select

  4. #4
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Help

    The op would still have to move this part to the next line in each case wouldn't he?

    Code:
    Label2.Caption = "Nicely done!" And Image1.Visible = True
    Code:
    Label2.Caption = "Nicely done!" 
    Image1.Visible = True
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help

    Either that or use a string which gets passed to the label at the end.

    It doesn't really matter which way though.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Help

    first things first

    replace

    If Text1 >= 86 Then

    by

    If Val(Text1.Text) > 86 or Val(Text1.Text) = 86 then

    and so on and so forth..
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    20

    Re: Help

    Thanks for the help guys. i may have some more school projects i need help with in the future.

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