CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Posts
    24

    using Or statement

    can someone help me im trying to use the Or statement in a project

    i have a checkbox which gets checked when i click a label then i want to see if when a cmd button is clicked weather the outcome is in the fist 10 numbers or the second. bit like a roulette table

    the code i have which isnt working(that i need help on) is this

    Code:
    Private Sub lblEndResult_Change()
    if Check1(0).Value = 1 then
       if lblEndResult.Caption >0 Or <10 then
       MsgBox "Number is Less Than 10",vbOkOnly, "Less Than 10"
    
    end if
    end if
    End Sub
    now when i try to use this code it comes up in red telling me its not gonna work. why?

    can i not use the Or statement here.

  2. #2
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: using Or statement

    Change to
    if lblEndResult.Caption >0 Or lblEndResult.Caption<10 then
    but I think you want an And instead of the Or

  3. #3
    Join Date
    Dec 2008
    Posts
    24

    Re: using Or statement

    ThankYou It Worked A Treat.

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: using Or statement

    I would add another bit to this condition
    Code:
    If Val(lblEndResult.Caption) > 0 Or Val(lblEndResult.Caption) < 10 Then
    This way, I would be sure that even if there is a string the caption my program won't crash. You can test your code by putting a non-numeric Caption to the label and see how it blows up.

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

Featured