hi,, can anyone tell me how to use constraints in VB.net,,, like i mean to say if i have value 10 to 20cm,, or it can b some other also,, n i wana put some constraint to that if the user wana put value above or below this value , it will not work,,,is it possible, tell me coding

I can only know in this that how to constant a text like i can put a password and username,, if it match with that which i hav set before it will work, other wise msg comes TRY AGAIN.I know only this

but i wana know how to use greater than or less than option in this. hope u understand ma question???

Recommended Answers

All 3 Replies

If you are using number then the NumberUpDown control can be used as it has a property for min and max allowed plus it only allows numbers

If you are using textboxes then you will have to check the value entered in the OnLeave sub

can you plz send me the detail or code for that,, coz i m really sorry to understand wat u mean??????


For a NumberUpDown box in the Properties screen (Lower Right) you can set a value called Maximum and Minimum or do it in code

numWidth.Maximum = 20
numWidth.Minimum = 5

This will stop the person setting it passed the range

For a textbox you will have to handle this in code

Private Sub txtWidth_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtWidth.Leave
   If txtWidth.text < 5 or txtWidth.text > 20 Then
      MsgBox("Width is not in range!")
   End If
End Sub

This will force the person to change it until it is in range

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.