Quantcast
Channel: Only allow numeric values in the textbox - Stack Overflow
Browsing latest articles
Browse All 14 View Live

Answer by EduTronics for Only allow numeric values in the textbox

Just write simple 1 lineIn text changeText1.text1=val(text1.text)

View Article



Answer by Juan David Benitez for Only allow numeric values in the textbox

Just select the control and the keyPress method and the IDE create the next method for you. Then add the next code inside the methodPrivate Sub txtControl_KeyPress(KeyAscii As Integer) KeyAscii =...

View Article

Answer by Mags Iren for Only allow numeric values in the textbox

TRY THIS CODE: DISABLES LETTER(A-Z,a-z) AND ACCEPTS BACKSPACE, DOTS, COMMAS AND NUMBERS(0-9) =)Private Sub Text1_KeyPress(KeyAscii As Integer)If Not (KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ)...

View Article

Answer by Chhornkimchheng for Only allow numeric values in the textbox

I used this code in my project:Private Sub txtReceiptID_KeyPress(KeyAscii As Integer)Dim Keychar As StringIf KeyAscii > 31 Then Keychar = Chr(KeyAscii) If Not IsNumeric(Keychar) Then KeyAscii = 0...

View Article

Answer by JEREMIAH EasySoft for Only allow numeric values in the textbox

Try this code: Private Sub Text1_Change() textval = Text1.Text If IsNumeric(textval) Then numval = textval Else Text1.Text = CStr(numval) End IfEnd Sub

View Article


Answer by saeid for Only allow numeric values in the textbox

If Len(Text2.Text) > 0 Then If IsNumeric(Text2.Text) = False Then Text2.SetFocus CreateObject("WScript.Shell").SendKeys "{BACKSPACE}" End IfEnd If

View Article

Answer by Shamsudheen Abubakker for Only allow numeric values in the textbox

I usually use this code:Private Sub text1_KeyPress(KeyAscii As Integer) If Not IsNumeric(Chr(KeyAscii)) And Not KeyAscii = 8 Then KeyAscii = 0 End IfEnd SubHope this helps.

View Article

Answer by Koko for Only allow numeric values in the textbox

The following may be used for whole numbers: Private Sub text1_KeyPress(KeyAscii As Integer) If Not IsNumeric(text1.Text & Chr(KeyAscii)) And Not KeyAscii = 8 Then KeyAscii = 0 if (KeyAscii>=43)...

View Article


Answer by Gung Ariana for Only allow numeric values in the textbox

i usually use this code:Private Sub text1_KeyPress(KeyAscii As Integer) If Not IsNumeric(text1.Text & Chr(KeyAscii)) And Not KeyAscii = 8 Then KeyAscii = 0End Sub

View Article


Answer by jac for Only allow numeric values in the textbox

I let the API do it for me. I add this function to a .bas module and call it for any edit control that I need to set to numeric only.Option ExplicitPrivate Const ES_NUMBER = &H2000&Private...

View Article

Answer by pinichi for Only allow numeric values in the textbox

Right click on control box > component > Control -> Microsoft Masked Edit Control 6.0.Or with normal textbox:Private Sub Text1_Validate(Cancel As Boolean) Cancel = Not IsNumeric(Text1.Text)End...

View Article

Answer by Thunder for Only allow numeric values in the textbox

In the text box text Change event, check if the entered value is a number. If it's not a number then set the old value back again.Dim textval As StringDim numval As StringPrivate Sub TextBox1_Change()...

View Article

Answer by zsalzbank for Only allow numeric values in the textbox

Check this out:http://www.vbforums.com/showthread.php?t=350067You need to check each keypress, or you can do one validation at the end.

View Article


Only allow numeric values in the textbox

I want to make a TextBox control that only accepts numerical values.How can I do this in VB6?

View Article
Browsing latest articles
Browse All 14 View Live


Latest Images