Salutations;
I have 5 texboxex on my form, i want to calculage the numeric value in side these boxes, and the total must appear in the textbox 6.
Using Access and VB6
Simple question, reply soon.
thanx in advance
Printable View
Salutations;
I have 5 texboxex on my form, i want to calculage the numeric value in side these boxes, and the total must appear in the textbox 6.
Using Access and VB6
Simple question, reply soon.
thanx in advance
VB Code:
Text6.Text = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
My Dear Hack,
It is not working, i know the code you wrote is OK, but it not working, i am using already this code, take a look, but it is not working plz help.
Code on ****text1.text****
Private Sub text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
text2.SetFocus
End If
Select Case KeyAscii
Case 48 To 57, 46, 8
'do nothing
Case Else
KeyAscii = 0
End Select
End Sub
**************** this is code is same on rest of 4 text boxes.
After entering value in each text box i need the sum ov values in textbox 6, as i Questioned before.
and in ********** textbox 6 i write this code...
Private Sub text6_Change()
text6.Text = Val(text1.Text) + Val(text2.Text) + Val(text3.Text) + Val(text4.Text)
End Sub
But it is not working.. plz help,
Why are you putting it in the Keypress event of text1 as opposed to the click event of a command button?
What does "its not working" mean? What is happening?
Mr. Hack , plz check it again, i write it in explain..
Thisis never ever going to get executed unless you type something into Text6. Actually entering something into a textbox is the ONLY way the Change event ever fires.VB Code:
Private Sub text6_Change() text6.Text = Val(text1.Text) + Val(text2.Text) + Val(text3.Text) + Val(text4.Text) End Sub
So, again, I ask, why not put that code in a command button's click event, and after everything is entered into all five textboxes, click the button and get the total?
Plucky why you putting this:
text6.Text = Val(text1.Text) + Val(text2.Text) + Val(text3.Text) + Val(text4.Text)
in the text6_change event?
Why have you posted this question twice?
So you want to calculate as the user types. In that case you need to write code in the change event for each text box.
Call a function in the textbox change event.
In the function write the adding up code that Hack has posted.
Sir, Whythetorment
Becuase i need total of values those i entered in text1.text, text2.text...... text5.text text6.text,
Is it wrong mathod?
Mr. Abhijit,
sorry, i don't know how to write function :(
Plucky,
Its not right. You will have to place the code in the change event of the other text boxes. Thats when its going to work.
yes but like hack said its not going to work like that unless you type in text6. place the code in the text1_change, text2_change, etc.
public sub text1_change()
text6.Text = Val(text1.Text) + Val(text2.Text) + Val(text3.Text) + Val(text4.Text)
end sub
Mr. Hack, thank you very much, its working now..
i just put keypress in text6, now it is working..
Thanx again you are all great..
You never did say why you aren't putting the calculation in command button's click event instead of each textbox's change event, but I'm guessing that you want Text6 to reflect a running total of the other 5 box's input. Is that right?Quote:
Originally Posted by Plucky
By the way, if this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.
Thank you. :)