0

hi need codes for displaying a negative value eg ($-1000) in the balance txt when a person pays more cash here are my codes
Private Sub CmdCalc_Click()
'to declare variables
Dim Nam As String
Dim Unit As String
Dim Amt As Currency
Dim Bal As Currency
Dim Tot As Currency
Dim pay As Currency


Const Service_rate = "Ksh3500"

Nam = Val(TxtName.Text)
Tot = Val(TxtTotal.Text)
Unit = Val(TxtUnitNo.Text)
Amt = Val(TxtAmount.Text)
Bal = Val(TxtBal.Text)
pay = Val(TxtPay.Text)


Tot = Amt + 0
Bal = Service_rate - Tot

TxtTotal.Text = Format(Tot, "Currency")
TxtBal.Text = Format(Bal, "Currency")
TxtAmount.Text = Format(Amt, "Currency")
TxtPay.Text = Format(pay, "Currency")
TxtPay.Text = Service_rate

If FrmTikmash.OptFull = True Then
TxtStatus = "Paid"
End If
If FrmTikmash.OptBal = True Then
TxtStatus = "Has Balance"
End If
If FrmTikmash.OptNot = True Then
TxtStatus = "Not Paid"
End If
If FrmTikmash.OptIOU = True Then
TxtStatus = "IOU"
End If

End Sub

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vb5prgrmr
0

Hi Masterace,

Here is one way you can do. Use Integer instead of Currency if you are not sure how to use Currency, just like below.

Private Sub cmdCalculate_Click()
Dim Amt As Integer
Dim Tot As Integer

Amt = Val(txtAmount.Text)
Tot = Val(txtTotal.Text)
txtBalance.Text = Tot - Amt
End Sub

Let us know if you need more help.
Hope this helps.

0

Well using integers will not allow for the showing of cents or decimal value portions of a dollar...

MsgBox Format(-1000.45, "$#,#.00;-$#,#.00")

Good Luck

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.