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

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.