List Info

Thread: Text Box




Text Box
country flaguser name
United States
2007-10-22 22:51:16

Help me Please. I need the Text box only accepts numbers. Please letme know how to do that.
THANK YOU.
 
Regards
 
Manuel Camaro

__._,_.___
.

__,_._,___
Re: Text Box
country flaguser name
United States
2007-10-22 23:01:28

hi,
 
wow, something i can answer.
 
you use is numeric.
 
if text1.text is numeric then
move on
else
msgbox "please only enter numbers"
end if
 
 
 
----- Original Message -----
Sent: Monday, October 22, 2007 10:51 PM
Subject: [helpwithvb] Text Box

Help me Please. I need the Text box only accepts numbers. Please letme know how to do that.
THANK YOU.
 
Regards
 
Manuel Camaro

__._,_.___
.

__,_._,___
RE: Text Box ( allow numbers only )
country flaguser name
United States
2007-10-23 00:34:07


Good Morning Manuel,

I think everyone has given you the answer, but
if you would like some additional information....

VB-6

There is an API solution to this, but it is
for whole numbers only, no decimal point allowed.
Let me know if you want / need the API solution.

Here is the normal basic code for the KeyPress Event,
in the attached text file, but if you cannot receive
the attachment, then let us know, and I will paste
the code into another, new, e-mail to the list.

Please test the code in the attachment, to double-check,
and if you need to look for minus and plus signs, and
the decimal point, I have some code that was written
by two really, really smart people, to handle that.

Let me know.

All The Best,
Steve
.
Sent out after Mid-Nite....
01:30 EST Tuesday, October 23, 2007
.
.

________________________________________
From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com]
On Behalf Of Manual Camaro
Sent: Monday, October 22, 2007 11:51 PM
To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
Subject: [helpwithvb] Text Box

Help me Please.

I need the Text box only accepts numbers.

Please let me know how to do that.

THANK YOU.
 
Regards
 
Manuel Camaro
.
.

__._,_.___
.

__,_._,___
  
Re: Text Box
country flaguser name
United Kingdom
2007-10-23 02:39:59

This is the code I use in my calculater form.
 
Steve may have sent something similar (I haven't looked yet).
 
It assumes you have two or more textboxes in a control array.
 
Private Sub txtTB_KeyPress(Index As Integer, KeyAscii As Integer)
' Allows the use of the backspace
If KeyAscii = vbKeyBack Then
 ;  
    ' Only allows numbers to be entered
   ElseIf VBA.Chr$(KeyAscii) Like "[0-9]" Then
   ' Only allows the "." to be entered and no other
ElseIf KeyAscii = 46 Then
Else
' Prevents accidental use of other characters
    KeyAscii = 0
End If
End Sub
 
Hope you find this useful?
 
All the best,
 
Geoff

----- Original Message -----
Sent: Tuesday, October 23, 2007 4:51 AM
Subject: [helpwithvb] Text Box

Help me Please. I need the Text box only accepts numbers. Please letme know how to do that.
THANK YOU.
 
Regards
 
Manuel Camaro


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21/10/2007 15:09

__._,_.___
.

__,_._,___
Re: Text Box
country flaguser name
United States
2007-10-23 07:59:16

Geoff,
Would the OnChange event for the textbox also work? I do not have my
laptop with me to test it.

Tim

>; This is the code I use in my calculater form.
>
> Steve may have sent something similar (I haven't looked yet).
>
> It assumes you have two or more textboxes in a control array.
>
> Private Sub txtTB_KeyPress(Index As Integer, KeyAscii As Integer)
> ' Allows the use of the backspace
> If KeyAscii = vbKeyBack Then
>;
> ' Only allows numbers to be entered
> ElseIf VBA.Chr$(KeyAscii) Like "[0-9]" Then
>; ' Only allows the "." to be entered and no other
> ElseIf KeyAscii = 46 Then
>; Else
>; ' Prevents accidental use of other characters
> KeyAscii = 0
> End If
> End Sub
>
> Hope you find this useful?
>
> All the best,
>
> Geoff
>
>
> ----- Original Message -----
> From: Manual Camaro
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
> Sent: Tuesday, October 23, 2007 4:51 AM
> Subject: [helpwithvb] Text Box
>
>
>
> Help me Please. I need the Text box only accepts numbers. Please letme
> know how to do that.
> THANK YOU.
>;
> Regards
>
> Manuel Camaro
>
>
>
>
> ----------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date:
> 21/10/2007 15:09
>

__._,_.___
.

__,_._,___
Re: Text Box
country flaguser name
United Kingdom
2007-10-23 09:24:38

Hello Tim,
 
I have to admit, I have never tried the Text1_Change with this code. The Text1_KeyPress event seems to be the most logical place to put the code.
 
Now that I have tried it, regardless of what is typed into the Textbox, VB6 responds with an error message:
 
Variable not defined
 
It highlights the KeyAscii keyword, so the answer is: No.
 
All the best,
 
Geoff
----- Original Message -----
Sent: Tuesday, October 23, 2007 1:59 PM
Subject: Re: [helpwithvb] Text Box

Geoff,
Would the OnChange event for the textbox also work? I do not have my
laptop with me to test it.

Tim

> This is the code I use in my calculater form.
>
> Steve may have sent something similar (I haven't looked yet).
>
> It assumes you have two or more textboxes in a control array.
>;
> Private Sub txtTB_KeyPress(Index As Integer, KeyAscii As Integer)
> ' Allows the use of the backspace
> If KeyAscii = vbKeyBack Then
>
> ' Only allows numbers to be entered
> ElseIf VBA.Chr$(KeyAscii) Like "[0-9]" Then
> ' Only allows the "." to be entered and no other
> ElseIf KeyAscii = 46 Then
> Else
> ' Prevents accidental use of other characters
> KeyAscii = 0
> End If
> End Sub
>
> Hope you find this useful?
>
> All the best,
>
> Geoff
>
>
> ----- Original Message -----
> From: Manual Camaro
>; To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; Sent: Tuesday, October 23, 2007 4:51 AM
> Subject: [helpwithvb] Text Box
>
>
>
> Help me Please. I need the Text box only accepts numbers. Please letme
> know how to do that.
> THANK YOU.
>
> Regards
>
> Manuel Camaro
>;
>
>
>
> ----------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date:
> 21/10/2007 15:09
>


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22/10/2007 19:57

__._,_.___
.

__,_._,___
Re: Text Box
country flaguser name
United States
2007-10-23 10:14:16

Ah, ok. Thank you sir.

> Hello Tim,
>;
> I have to admit, I have never tried the Text1_Change with this code. The
> Text1_KeyPress event seems to be the most logical place to put the code.
>
> Now that I have tried it, regardless of what is typed into the Textbox,
> VB6 responds with an error message:
>
>; Variable not defined
>
> It highlights the KeyAscii keyword, so the answer is: No.
>
> All the best,
>
> Geoff
> ----- Original Message -----
> From: Tim Lewis
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
> Sent: Tuesday, October 23, 2007 1:59 PM
> Subject: Re: [helpwithvb] Text Box
>
>
> Geoff,
> Would the OnChange event for the textbox also work? I do not have my
> laptop with me to test it.
>
> Tim
>
> > This is the code I use in my calculater form.
> >
>; > Steve may have sent something similar (I haven't looked yet).
> >
>; > It assumes you have two or more textboxes in a control array.
> >
>; > Private Sub txtTB_KeyPress(Index As Integer, KeyAscii As Integer)
> > ' Allows the use of the backspace
> > If KeyAscii = vbKeyBack Then
>; >
>; > ' Only allows numbers to be entered
> > ElseIf VBA.Chr$(KeyAscii) Like "[0-9]" Then
>; > ' Only allows the "." to be entered and no other
> > ElseIf KeyAscii = 46 Then
>; > Else
>; > ' Prevents accidental use of other characters
> > KeyAscii = 0
> > End If
> > End Sub
> >
>; > Hope you find this useful?
> >
>; > All the best,
> >
>; > Geoff
> >
>; >
>; > ----- Original Message -----
> > From: Manual Camaro
> > To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
> > Sent: Tuesday, October 23, 2007 4:51 AM
> > Subject: [helpwithvb] Text Box
> >
>; >
>; >
>; > Help me Please. I need the Text box only accepts numbers. Please letme
> > know how to do that.
> > THANK YOU.
>; >
>; > Regards
> >
>; > Manuel Camaro
> >
>; >
>; >
>; >
>; > ----------------------------------------------------------
> >
>; >
>; > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date:
> > 21/10/2007 15:09
> >
>;
>
>
>
>
>
> ----------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date:
> 22/10/2007 19:57
>

__._,_.___
.

__,_._,___
RE: Text Box
country flaguser name
United States
2007-10-23 10:20:20

Hi Tim and Geoff,
 
This is what I use for text boxes
 
Private Sub txtIPP1_KeyPress(KeyAscii As Integer)
  Select Case KeyAscii
    Case 1
   ;   '  1 Ctrl A Select All
      txtIPP1.SelStart = 0
   ;   txtIPP1.SelLength = Len(txtIPP1.Text)
  ;    KeyAscii = 0
   ; Case 3, 8, 22, 24, 48 To 57
 ;     '  3 Ctrl C Copy
      '  8 Backspace
      ' 22 Ctrl P Paste
      ' 24 Ctrl X Cut
      ' 48 to 57 'Numbers
    Case Else
 ;     KeyAscii = 0
  End Select
 
End sub
 
-Joe


From: helpwithvbyahoogroups.com [mailto:helpwithvbyahoogroups.com] On Behalf Of geoff Smith
Sent: Tuesday, October 23, 2007 10:25 AM
To: helpwithvbyahoogroups.com
Subject: Re: [helpwithvb] Text Box

Hello Tim,
 
I have to admit, I have never tried the Text1_Change with this code. The Text1_KeyPress event seems to be the most logical place to put the code.
 
Now that I have tried it, regardless of what is typed into the Textbox, VB6 responds with an error message:
 
Variable not defined
 
It highlights the KeyAscii keyword, so the answer is: No.
 
All the best,
 
Geoff
----- Original Message -----
Sent: Tuesday, October 23, 2007 1:59 PM
Subject: Re: [helpwithvb] Text Box

Geoff,
Would the OnChange event for the textbox also work? I do not have my
laptop with me to test it.

Tim

> This is the code I use in my calculater form.
>
> Steve may have sent something similar (I haven't looked yet).
>
> It assumes you have two or more textboxes in a control array.
>;
> Private Sub txtTB_KeyPress(Index As Integer, KeyAscii As Integer)
> ' Allows the use of the backspace
> If KeyAscii = vbKeyBack Then
>
> ' Only allows numbers to be entered
> ElseIf VBA.Chr$(KeyAscii) Like "[0-9]" Then
> ' Only allows the "." to be entered and no other
> ElseIf KeyAscii = 46 Then
> Else
> ' Prevents accidental use of other characters
> KeyAscii = 0
> End If
> End Sub
>
> Hope you find this useful?
>
> All the best,
>
> Geoff
>
>
> ----- Original Message -----
> From: Manual Camaro
>; To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; Sent: Tuesday, October 23, 2007 4:51 AM
> Subject: [helpwithvb] Text Box
>
>
>
> Help me Please. I need the Text box only accepts numbers. Please letme
> know how to do that.
> THANK YOU.
>
> Regards
>
> Manuel Camaro
>;
>
>
>
> ----------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date:
> 21/10/2007 15:09
>


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22/10/2007 19:57

__._,_.___
.

__,_._,___
[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )