|
-
Apr 22nd, 2003, 02:14 AM
#1
Thread Starter
Hyperactive Member
Adding up
I have 5 text boxes. When I put a number in the first text box I want the same number to appear in the 5th text box. When I put a number in the second text box I want it to appear in the 5th text box, but now its added to the the first number and so on to the fourth text box. I want this to happen as the user types in the numbers.
Thanks in advance
-
Apr 22nd, 2003, 02:37 AM
#2
Addicted Member
VB Code:
text5.text=text1.text & text2.text
P.S. Sorry for my poor English...
-
Apr 22nd, 2003, 02:49 AM
#3
Retired VBF Adm1nistrator
VB Code:
Private Sub Text1_Change()
Text5.Text = CLng(Text1.Text) + CLng(Text2.Text)
End Sub
You should use a control array and loop through the textboxes if you're going to be adding more than just the two TextBoxes
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Apr 22nd, 2003, 03:04 AM
#4
Fanatic Member
Are you trying to add the number entered into each texbox to your 5th textbox ?
could try this I guess?
VB Code:
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Text5.Text = Val(Text5.Text) + Val(Text1.Text)
End Sub
Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
Text5.Text = Val(Text5.Text) + Val(Text2.Text)
End Sub
Private Sub Text3_KeyUp(KeyCode As Integer, Shift As Integer)
Text5.Text = Val(Text5.Text) + Val(Text3.Text)
End Sub
Private Sub Text4_KeyUp(KeyCode As Integer, Shift As Integer)
Text5.Text = Val(Text5.Text) + Val(Text4.Text)
End Sub
but like plenderj said, you'd be better off using control array for this purpose.
Last edited by daydee; Apr 22nd, 2003 at 03:08 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|