WastinAway
Technical User
This is what I have so far for my program I am trying to run. It works fine but I need it to do one more thing. Notice the script in bold print! This is where i am stuck!
I need it to take the existing data in the saved file and add it to the new total I just entered and give me a new running total every time I execute the program. So I can keep the running total and not have to put it in everytime I run the program. I hope this is clear. I really need help with this, thanks!!
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
I need it to take the existing data in the saved file and add it to the new total I just entered and give me a new running total every time I execute the program. So I can keep the running total and not have to put it in everytime I run the program. I hope this is clear. I really need help with this, thanks!!
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