Help Needed Please With Basic Program

keyring90 May 20, 2014

  1. keyring90

    keyring90 Newbie
    235/282

    Joined:
    May 8, 2011
    Messages:
    196
    Likes Received:
    60
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Snap City
    Console:
    Xbox
    Hey, I'm looking to make a program where i have to write suitable code which could be attached to a command button in a form which would ask a user to input a number, if the number is an odd number display in a message box the text: "Your number is odd" and if the number is even display in a message box the text: "Your number is even"

    Now with my terrible coding i've somehow managed to get it working slightly. The problem is any number shows Even? I will post my code below. Any help would be amazing. Thanks.

    P.S Remember i have no knowledge in coding and hate it so far.
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim TextBox1 As Integer
    
            If (TextBox1 Mod 2 = 1) Then
    
                MessageBox.Show("Your number is odd")
    
            Else
    
                MessageBox.Show("Your number is even")
            End If
        End Sub
    End Class
    
     
  2. begallegal1

    begallegal1 Medicine Man Lifetime Gold TeamXPG
    235/282

    Joined:
    Oct 31, 2011
    Messages:
    3,694
    Likes Received:
    3,131
    Trophy Points:
    235
    Gender:
    Male
    Location:
    In a Field of Green
    Console:
    Xbox
    I don't do VB so I may be wrong but try this , hope it helps ;)
    Code:
    If (TextBox1 Mod 2 = 0) Then
    
    MessageBox.Show("Your number is EVEN")
    
    Else
    
    MessageBox.Show("Your number is ODD")
     
  3. keyring90

    keyring90 Newbie
    0/47

    Joined:
    May 8, 2011
    Messages:
    196
    Likes Received:
    60
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Snap City
    Console:
    Xbox
    Thank for the reply. I just tried this and instead of saying even all the time, using this makes it say odd with any number? lol, this is weird.
     

Share This Page

Close