-
Hi, I am just a beginner with VB. I'm trying to get numbers to total on a form using text boxes. I can get it to work with a command_click but would prefer if it would total on it's own, no command_click button. eg: enter number in text1 number shows up also in text3 (assuming this is the totaling text box).
This is the code I'm using presently with the command_click.
Private Sub Command1_Click()
Dim intNoA As Integer
Dim intNoB As Integer
intNoA = Text1
intNoB = Text2
Text3 = intNoA + intNoB
End Sub
This is probably simple so please have patience with me.
I certainly appreciate you taking the time to respond to this request.
Thanks, newvbr
-
<?>
Code:
Private Sub Text2_Change()
Text3 = Val(Text1) + Val(Text2)
End Sub
'of course you will need to validate your text
'numbers only...for each box
Code:
'allow only numeric data in a textbox
Option Explicit
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
End Sub
[Edited by HeSaidJoe on 11-23-2000 at 02:41 PM]