I’m an information technology student and our professor asked us to create a program using visual basic 6.0 that would determine if a number is a even or odd. In addition, if the input is not a whole number or a letter, the program should return an error stating "Please Enter a number!" and if the number is even or odd the program should return a message stating "the number x(x=user input number) is even" or "the number x(x=user input number) is odd".

I’m a little clueless right now and would like some help on this.Thank you so much.

Private sub cmdOK_click()

Dim i as integer

// check whether number is a character

If val(txtinput.text)=0 then // val will return 0 for any non-n numeric numbers

Msgbox(“not valid number”)

Exit sub

End if

//check for whole number

i=val(txtinput.text) //i will take only the integer part of the number.

If i<>val(txtinput.text) then // if the integer part is not equal to entire number

Msgbox(“Not a whole number”)

Exit sub

Endif

If i Mod 2 == 0 then // If the remainder after division of the number by 2 is zero then

msgbox(“Number is even”)

else // The number is odd and the division remainder is not zero.

msgbox(“Number is Odd”)

endif

end sub