Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Validation Rule for TextBox

Results 1 to 4 of 4
Share This Thread →
  1. #1
    Dzak is offline Registered User
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Validation Rule for TextBox

    This is my first post here so Hi everyone.

    I am new to VB and I am creating program that calculate the area of the room and calculate the price of the paint etc. One of the restriction is that the height of the room must be between 2 and 6 and the length must be between 1 and 25. I have two text boxes, one for hight and one for length. I need to add validation rule for both of them. I tried few codes but none of the worked for me. I was still able to calculate any number.

    Thanks
    Dzak

  2. #2
    Dzak is offline Registered User
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    I forgot to add that I am using Windows Forms Application (I am not sure if it does matter or not).

  3. #3
    avasher is offline Registered User
    Join Date
    Feb 2013
    Location
    Toledo, OH
    Posts
    2
    Rep Power
    0
    Validation rules are generally set at the table level of a database design. However, you are using a smart form that will only use the variables for a temporary time, the time needed to perform your calculation. On the forms properties section for each of the controls, be sure that you can enter integer values. Look for a validation field to enter your min and max values. DO NOT use double quotes when assigning the int values. Should look something like this:

    Validation Rule: >=2 AND <=6
    Or
    Between 2 AND 6.
    Too many different ways to handle this validation. OPEN AN

  4. #4
    rajeshnannilam is offline Registered User
    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0
    Hi Dzak!

    First of all the easiest way is change the textbox to combobox and add item what you want only.

    Or

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    If Val(TextBox1.Text) > 6 Or Val(TextBox1.Text) < 2 Then

    MsgBox("You can entered between 2 to 6.", MsgBoxStyle.Information, My.Application.Info.ProductName)

    TextBox1.Text = ""

    End If

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Validation rule
    By udita in forum Microsoft Access Help
    Replies: 1
    Last Post: August 6th, 2009, 12:48 PM
  2. Validation Rule
    By KeiFeR123 in forum Microsoft Access Help
    Replies: 1
    Last Post: October 3rd, 2004, 09:53 PM
  3. textbox validation
    By x_c4_4u in forum Visual Basic Programming
    Replies: 3
    Last Post: September 13th, 2004, 02:14 AM
  4. Validation Rule
    By canadian in forum Microsoft Access Help
    Replies: 1
    Last Post: June 9th, 2004, 10:47 AM
  5. Validation Rule....Pls help...Thanks
    By raeleong in forum Microsoft Access Help
    Replies: 3
    Last Post: May 14th, 2004, 01:35 AM

ASP Free Advertisers and Affiliates