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
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")
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.