WastinAway
Technical User
I wrote a simple program that will tell me how much money out of paycheck goes where! BUt I came amongst a problem. Here is what happens. I enter a dollar ammount in a text box then hit calculate. it calculates 25% of and 75% of and puts it in seperate txtboxes. Then it takes the 75% txtbox and enters that ammount into a lstbox. After that amount is in the lstbox then I hit save. It saves that amount to a word document. after I save,I exit. When I run the progrma again it loads that amount from the word document into a new txtbox called running total. My problem is I want to add the data in the word document to the new total everytime one is entered so that I can keep a running total of what all is entered. SO I don't have to reenter all the info again. Thanks I hipe this is clear enough. HEre is what I have so far.
Private Sub cmdcalculate_Click()
Dim NetPay As Single, Percent As Single, Percent2 As Single
If IsNumeric(txtnet.Text) Then
NetPay = txtnet.Text
Percent2 = GetPercent2(NetPay)
Percent = GetPercent(NetPay)
txtdadper.Text = Format(Percent2, "currency")
txtpercent.Text = Format(Percent, "currency")
LstNetPay.AddItem Format$(Percent2, "currency")
DisplayTotal
Else
MsgBox "Number must be numeric", vbExclamation, "Input Error"
txtnet.Text = ""
txtnet.SetFocus
End If
End Sub
Private Sub cmdclear_Click()
txtnet.Text = ""
txtpercent.Text = ""
txtdadper.Text = ""
txtnet.SetFocus
End Sub
Private Function GetPercent(NetPay As Single) As Single
GetPercent = NetPay * 0.25
End Function
Private Sub DisplayTotal()
Dim counter As Integer
Dim total As Single
For counter = 0 To LstNetPay.ListCount - 1
total = total + LstNetPay.List(counter)
Next counter
txttotal.Text = Format$(total, "currency")
End Sub
Private Sub mnufileclear_Click()
LstNetPay.Clear
DisplayTotal
End Sub
Private Sub mnufileexit_Click()
Unload Me
End Sub
Private Function GetPercent2(NetPay As Single) As Single
GetPercent2 = NetPay * 0.75
End Function
Private Sub Save_Click()
Open "Running Total" For Append As #1
Print #1, txttotal.Text
Close #1
End Sub
Private Sub form_load()
Open "Running total" For Input As #1
Do Until EOF(1)
Line Input #1, a
txtruntotal = a
Loop
Close #1
End Sub
Private Sub cmdcalculate_Click()
Dim NetPay As Single, Percent As Single, Percent2 As Single
If IsNumeric(txtnet.Text) Then
NetPay = txtnet.Text
Percent2 = GetPercent2(NetPay)
Percent = GetPercent(NetPay)
txtdadper.Text = Format(Percent2, "currency")
txtpercent.Text = Format(Percent, "currency")
LstNetPay.AddItem Format$(Percent2, "currency")
DisplayTotal
Else
MsgBox "Number must be numeric", vbExclamation, "Input Error"
txtnet.Text = ""
txtnet.SetFocus
End If
End Sub
Private Sub cmdclear_Click()
txtnet.Text = ""
txtpercent.Text = ""
txtdadper.Text = ""
txtnet.SetFocus
End Sub
Private Function GetPercent(NetPay As Single) As Single
GetPercent = NetPay * 0.25
End Function
Private Sub DisplayTotal()
Dim counter As Integer
Dim total As Single
For counter = 0 To LstNetPay.ListCount - 1
total = total + LstNetPay.List(counter)
Next counter
txttotal.Text = Format$(total, "currency")
End Sub
Private Sub mnufileclear_Click()
LstNetPay.Clear
DisplayTotal
End Sub
Private Sub mnufileexit_Click()
Unload Me
End Sub
Private Function GetPercent2(NetPay As Single) As Single
GetPercent2 = NetPay * 0.75
End Function
Private Sub Save_Click()
Open "Running Total" For Append As #1
Print #1, txttotal.Text
Close #1
End Sub
Private Sub form_load()
Open "Running total" For Input As #1
Do Until EOF(1)
Line Input #1, a
txtruntotal = a
Loop
Close #1
End Sub