Computing.Net > Forums > Programming > VB Totals

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

VB Totals

Reply to Message Icon

Original Message
Name: bertyzz
Date: December 2, 2002 at 04:00:47 Pacific
Subject: VB Totals
OS: Xp Pro
CPU/Ram: 1.1 Gig 256 DDR
Comment:

Hi guys,
Just an easy question for all you VB pro's out there!!
Can anyone tell me how to store an 'X' amount of numbers within a variable and the then display the total value of all the numbers stored in the given variable.

Eg: Enter number 1, click cmd1 to move the number to a variable. Enter another number 1 and again click cmd1 to add this number to the number already in the variable.

Then click cmd2 to dispaly the value of the numbers stored in the variable (this should be 2).

Any help would be really great guys as I have to write a currency conversion program for my college assignment which keeps running totals of number of transactions, amount of currency etc and I have to get it finished in 4 days!!!

Thanks guys

Berty


Report Offensive Message For Removal


Response Number 1
Name: Critter
Date: December 2, 2002 at 04:23:00 Pacific
Reply: (edit)

I think the following may give you a general idea on how to get started. Make a form, and put a text box, a command button, and a label on it. Then add the following code...

Private Sub Command1_Click()

Static dblTotal As Double

dblTotal = dblTotal + Val(Text1.Text)
Label1.Caption = "Total = " & dblTotal
Text1.Text = ""
Text1.SetFocus

End Sub

If you still want to go with the second command button, declare dblTotal at the top of the form code in the general declarations and then just get cmd2 to display a message box or something.


Report Offensive Follow Up For Removal

Response Number 2
Name: Berty
Date: December 2, 2002 at 06:42:17 Pacific
Reply: (edit)

Hi Critter,
Thanks for the advice, I will give it a go in a minute and let you know how I get on!!!

Thanks alot.

Berty :)


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software