|
-
Jan 4th, 2011, 03:14 AM
#1
Thread Starter
Junior Member
-
Jan 4th, 2011, 04:31 AM
#2
Re: How to sum up?
if you want the textbox holding the total hrs to show the sum automatically you need to code each textbox holding entries (except the one holding the total hrs) to do the addition after the entry has changed. I'd suggest to use the _Lostfocus Event to hold the code.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 4th, 2011, 08:47 AM
#3
Re: How to sum up?
opus is correct. Another event you can try is _TextChanged depending on how you wish your app to respond.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Jan 5th, 2011, 05:30 AM
#4
Thread Starter
Junior Member
Re: How to sum up?
can you guys provide me with a sample code...it could help me alot!!!
-
Jan 5th, 2011, 05:55 AM
#5
Addicted Member
Re: How to sum up?
Ok If I am understand right you have 4 textbox - one for name , one for base,one for fleet and one who have to show the sum of the hours - total hrs Then Your code will look like this:
Code:
Form Load:
Dim Name As String
txtName.Text = Name - after that you can call Name and the name will be saved but when you close the program will disappear.
Timer 1 'cos you wan't it without button or something
txtTotalhrs.Text = Val(txtBase) + Val(txtFleet)
For the Val() I am agree to I just missed.
Last edited by mitko29; Jan 5th, 2011 at 11:39 AM.
-
Jan 5th, 2011, 06:03 AM
#6
Re: How to sum up?
 Originally Posted by mitko29
Ok If I am understand right you have 4 textbox - one for name , one for base,one for fleet and one who have to show the sum of the hours - total hrs Then Your code will look like this:
Code:
Form Load:
Dim Name As String
Name = txtName.Text - after that you can call Name and the name will be saved but when you close the program will disappear.
Timer 1 'cos you wan't it without button or something
txtBase + txtFleet = txtTotalhrs.Text
WTH is that?
All of that in Form_Load? That way any input after the Fom_load will not be calculated!
With which code would that String be saved? I don't see any!
What are you using Timer 1 for?
At last you are trying to add two Strings, but do even that in the wrong order!
@skywalker: disregard the previous post!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 5th, 2011, 06:11 AM
#7
Re: How to sum up?
assuming you have textboxes named "txtbxOnBase" and "txtbxOnFleet" and for the Result a textbox named "txtbxTotal".
Code:
Private Sub txtbxOnBase_LostFocus()
txtbxTotal.Text = Val(txtbxOnBase.Text)+Val(txtbxOnFleet.Text)
End Sub
Private Sub txtbxOnFleet_LostFocus()
txtbxTotal.Text = Val(txtbxOnBase.Text)+Val(txtbxOnFleet.Text)
End Sub
If you would have the textboxes in an array, you would need this Sub only once.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 5th, 2011, 08:29 AM
#8
Addicted Member
Re: How to sum up?
He want something who will show result without clicking any button or something for that I put it in Timer, he said that the value in txtbxOnBase and txtbxOnFleet will be already entered with some value.
There is nothing wrong in my code and my idea was the same,I don't write how to save it 'cos he can read it here in the forum,there is so many Topics.
I said that "the String wouldn't be saved parmanent"
And If he wan't to add more names - let's change it,what is the problem ?
I am not here to write his homework or some home idea I just only give a example the same you do.
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
|