In textbox i want to enter only number not any alphabates. please tell how i code that
17 5620 gits 5,390
Expert Mod 4TB
hi ...
what textboxes are you talking about? is it a webpage?
kind regards
... and what language?
kind regards,
Jos
In visual basic i put a textbox and i want to enter in that textbox only numeric value alphabete are not allowed .please how can i do it
hi ...
what textboxes are you talking about? is it a webpage?
kind regards
In visual basic i put a textbox and i want to enter in that textbox only numeric value alphabete are not allowed .please how can i do it
... and what language?
kind regards,
Jos
In visual basic i put a textbox and i want to enter in that textbox only numeric value alphabete are not allowed .please how can i do it
In visual basic i put a textbox and i want to enter in that textbox only numeric value alphabete are not allowed .please how can i do it
Moved to VB forum
Change Text1 to the name of your TextBox: -
Private Sub Text1_Change()
-
Dim CurrentPos As Long
-
Dim CurrentChar As String
-
-
CurrentPos = 1
-
While CurrentPos <= Len(Text1.Text)
-
CurrentChar = Mid(Text1.Text, CurrentPos, 1)
-
-
If Not (Asc(CurrentChar) >= 48 And Asc(CurrentChar) <= 57) Then
-
Text1.Text = Replace(Text1.Text, CurrentChar, "")
-
End If
-
-
CurrentPos = CurrentPos + 1
-
Wend
-
-
Text1.SelStart = Len(Text1.Text)
-
End Sub
-
If you want to also be able to enter a decimal point then change this one line: If Not (Asc(CurrentChar) >= 48 And Asc(CurrentChar) <= 57) Then
into this one line: -
If Not ((Asc(CurrentChar) >= 48 And Asc(CurrentChar) <= 57) or currentchar=".") Then
-
thank u for code but it gives error that
Run time error 5:
Invalid proceduer call or argument
this line
If Not (Asc(CurrentChar) >= 48 And Asc(CurrentChar) <= 57) Then
why it is
Run time error 5:
Invalid proceduer call or argument
this line
If Not (Asc(CurrentChar) >= 48 And Asc(CurrentChar) <= 57) Then
You must not be using VB6 then.
Seems the version you're using doesn't have the Asc() function.
If anyone used to .NET knows its equivalent to Asc(), it would be nice to hear from them now. =P
In visual basic i put a textbox and i want to enter in that textbox only numeric value alphabete are not allowed .please how can i do it
Hi,
Write this in KeyPress Event of TextBox: -
If keyAscii <> 8 Then
-
If Instr("0123456789", Chr(KeyAscii)) = 0 Then KeyAscii = 0
-
End If
-
REgards
Veena
Hi, -
If keyAscii <> 8 Then
-
If Instr("0123456789", Chr(KeyAscii)) = 0 Then KeyAscii = 0
-
End If
-
If keyAscii <> 8 Then
REgards
Veena
I think, you have to allow Ascii 13 also.
I think, you have to allow Ascii 13 also.
Ascii=13 = Enter key,
If She wants to write code to move to next Control for enter key, then she has to check and write code for that..
BCoz, VB will not move to next control for Enter key by itself
Regards
Veena
Ascii=13 = Enter key,
If She wants to write code to move to next Control for enter key, then she has to check and write code for that..
BCoz, VB will not move to next control for Enter key by itself
Regards
Veena
Just think if she want to write code for any operation by keypress 13 then the above code change the Ascii to 0.
better allow Ascii 13.
Hi Hari,
Yes, thats what i wrote in last post, if she want to write any code, she has to check that Ascii code and Exit Sub. Write my code in the End,
She may want to write for other chars also, SpaceBar, . - / ..
REgards
Veena
Hi Hari,
Yes, thats what i wrote in last post, if she want to write any code, she has to check that Ascii code and Exit Sub. Write my code in the End,
She may want to write for other chars also, SpaceBar, . - / ..
REgards
Veena
Okay, But; usually space never comes in numbers entry.
Thanks for All detail replies.
I'm surprised nobody has suggested using the Masked Edit control. It allows you to control the type and format of data entered.
I really very thank my problem solved
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RelaxoRy |
last post by:
If I fill out the textfields properly with Name, Email etc in a row it
is fine. But if I fill out, for example, my Name, then tab twice, it
clears my entered value. How do I stop this?
All I...
|
by: Adam Clauss |
last post by:
I've an application which is using a multiline textbox to log the status of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.
As my task is fairly lengthy,...
|
by: David Smith |
last post by:
What I want to be able to do:
A textbox is available that the user can enter information into.
Specifically (for the purposes of this post), the user is asked to
enter a number, and that number...
|
by: John |
last post by:
Hello,
I'm fairly new in programming and was trying to input numbers in
textbox fields.
This works fine but I would like to use the Enter key as well to input
a number in a textbox the way you...
|
by: Keith |
last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
|
by: TS |
last post by:
for some reason, it posts to the server, but no click events of any buttons
on form fire. the button is the first one on the form. when the focus is
inside the textbox, it doesnt' work. if i click...
|
by: Wayne |
last post by:
There is probably a simple solution to this but:
I have a textbox that is bound to a number field in a table. The field
type is "double". If I enter a negative value directly into the table
it...
|
by: Stuart Shay |
last post by:
Hello All
I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a
Number in a TextBox and go to the page selected.
Since the OnClick Event does not work in ASP.NET 1.1 for a...
|
by: Mike |
last post by:
Is there a way to determine if a user deleted text in a asp:textbox?
I have a textbox were users can enter in a product number, then they click a button to see if the product numbers(s) exists in...
|
by: billa856 |
last post by:
Hi,
My Project is in MS Access 2002.
In that I have one form which I am using for data entry.
Now in that I have some TextBoxes like...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |