I have 3 TextBoxes in my Project Form , textbox1 is for taking Maximum_Marks, TextBox2 is for Minimum_Marks and the textbox3 is for taking Obtained_Marks ,but i dont want my Obtained_Marks textbox should take value Greater than Maximum_Marks textbox1 value or Less Than Minimum_Marks textbox2 value. i am trying to get a guidance on it

4 Years
Discussion Span
Last Post by Reverend Jim

I presume that the user enters numbers in all three textboxes then clicks a button to perform some action. In the button_click handler you get the numeric values from all three textboxes then do a comparison and display an error message if the Obtained_Marks value is outside the range. First you have to verify that each field is numeric. You can do that either by restricting entry to digits (there are several examples of how to do that in this forum), or by testing in code by

If Not IsNumeric(TextBox1.Text) Then
    MsgBox("Value of Maximum_Marks is not numeric")

Once you have validated the fields you can convert them to numbers (in this example, integers) by

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.