Even and odd numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angelroseblog
    New Member
    • Mar 2010
    • 2

    Even and odd numbers

    Hi i am trying to learn VB and i'm practising "if statements" what i would really like to do is use one if statement for if the shirts value is odd and another for if the shirts value is even, can anyone help.
    Thanks

    Angel

    Code:
     If shirts = 1 Then
                reg = 12
                markdown = 9
                savings = 3
            Else
                If shirts >= 2 And shirts < 25 Then
                    reg = 10 * shirts
                    markdown = reg * 0.75
                    savings = reg * 0.25
                Else
                    If shirts >= 25 Then
                        MessageBox.Show("Please contact the manager for a special price", "Bulk Order")
                    End If
                End If
            End If
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Im not sure if there's a function that does that, but while you find it, you can use MOD, here is an example:

    [CODE=vb]if shirts mod 2 = 0 then
    'do whatever you do with evens
    else
    'do what you do with odds
    end if[/CODE]

    HTH

    Comment

    • angelroseblog
      New Member
      • Mar 2010
      • 2

      #3
      That is fantastic, thank you!

      Comment

      Working...