| | |
Limit Textbox to 32
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
Morning All,
I would like to set a limit to a text box so that end user only can enter numbers from 1-32 and not more.
I have setup a validation on keypress to make it only work with numbers i.e digits and nothing else however I am not sure how to set it to only allow 1-32 numbers.
I tried
Dim i as integer
for i=1to32
if textbox2.text>i then
msgbox("not allowed")
end if
next
this however didn't work. I don't think I even wrote it right or not.
Could you please put me to the right direction.
Many thanks
Regards
Jay
I would like to set a limit to a text box so that end user only can enter numbers from 1-32 and not more.
I have setup a validation on keypress to make it only work with numbers i.e digits and nothing else however I am not sure how to set it to only allow 1-32 numbers.
I tried
Dim i as integer
for i=1to32
if textbox2.text>i then
msgbox("not allowed")
end if
next
this however didn't work. I don't think I even wrote it right or not.
Could you please put me to the right direction.
Many thanks
Regards
Jay
try this following code :
vb Syntax (Toggle Plain Text)
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged If Val(TextBox3.Text) > 32 Then TextBox3.Text = TextBox3.Text.Remove(0, Len(TextBox3.Text)) MsgBox("input under 33") End If End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Apr 2008
Posts: 11
Reputation:
Solved Threads: 0
Hello
In The Validate Event of textbox Just write
Faisal
In The Validate Event of textbox Just write
VB.NET Syntax (Toggle Plain Text)
if val(textbox2.text) <1 or val(textbox2.text) > 32 then msgbox "Not Allowed" End if
Faisal
•
•
•
•
Morning All,
I would like to set a limit to a text box so that end user only can enter numbers from 1-32 and not more.
I have setup a validation on keypress to make it only work with numbers i.e digits and nothing else however I am not sure how to set it to only allow 1-32 numbers.
I tried
Dim i as integer
for i=1to32
if textbox2.text>i then
msgbox("not allowed")
end if
next
this however didn't work. I don't think I even wrote it right or not.
Could you please put me to the right direction.
Many thanks
Regards
Jay
•
•
•
•
Morning All,
I would like to set a limit to a text box so that end user only can enter numbers from 1-32 and not more.
I have setup a validation on keypress to make it only work with numbers i.e digits and nothing else however I am not sure how to set it to only allow 1-32 numbers.
I tried
Dim i as integer
for i=1to32
if textbox2.text>i then
msgbox("not allowed")
end if
next
this however didn't work. I don't think I even wrote it right or not.
Could you please put me to the right direction.
Many thanks
Regards
Jay
Private Sub textbox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
if cint(textbox1.text) > 1 and cint(textbox1.text) <32 then
msgbox ("not allowed")
else
'do something
end if
End Sub
Last edited by naz82; Jun 27th, 2008 at 10:39 am.
![]() |
Similar Threads
- getElementById not retreiving values from ASP textbox (JavaScript / DHTML / AJAX)
- Limit Text box input (VB.NET)
- limiting the input in text box (Visual Basic 4 / 5 / 6)
- inputting a single character in a textbox (Visual Basic 4 / 5 / 6)
- Replicating Screen textbox.text to defined printed area (VB.NET)
- Get rid of the editing time limit!!!!! (DaniWeb Community Feedback)
- How do I store a 10 lines of sentence in a textbox (VB.NET)
- Character limit in textbox (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Form buttons problem.
- Next Thread: Using the combo box to set the Default Member and Value Member names
Views: 1399 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code combobox component convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog ftp generatetags google gridview hardcopy highlighting images inline input insert intel internet listview mobile monitor ms net networking objects output passingparameters picturebox picturebox1 port print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial server shutdown soap sorting survey syntax table tcp temperature text textbox timer toolbox trim update updown user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf






