×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Newbie Question - Format in a Label

Newbie Question - Format in a Label

Newbie Question - Format in a Label

(OP)
I am trying to currency format a label field (the final calculated result--LblEI.Caption) in a small calculator program I have written. I keep going over and over solutions in my books to try to make this label format the result as currency. The closest I can get it is below -- I really want the format as $###,### Can someone give me what I'm sure is an easy solution? Is it because my variables are not formatted correctly?
Thanks so much!

Private Sub BtnCalc_Click()

Dim Vara 'Attendance entry
Dim Varprc 'Peak Room Count entry
Dim EI 'EI if Attendance and PRC are equal

'declare variables
Vara = Val(TxtAttend.Text) 'Attendance
Varprc = Val(TxtPRC.Text) ' Peak Room Count
EI = Vara * 1.451

If (Vara = Varprc) Then
LblEI.Caption = EI
LblEI.Caption = Format(EI, "$###,###.000")

Else: Call BookingFormula1
End If
' If attendance and Peak Room Count are equal,
' there is a straight calculation -- the EI variable.
' If the values are not equal, BookingFormula1 is called
End Sub


Private Sub BookingFormula1()
Dim Vara ' Attendance from above
Dim Varprc& 'Peak Room Count from above
Dim XPrv ' adjusted Peak Room Count
Vara = Val(TxtAttend.Text) 'Attendance
Varprc = Val(TxtPRC.Text) 'Peak Room COunt
XPrv = Varprc * 1.8 'Adjusted Peak Room Count

If XPrv < Vara Then
LblEI.Caption = XPrv * 1.451
LblEI.Caption = Format(XPrv, "$###,###.000")
Else: LblEI.Caption = Vara * 1.451
LblEI.Caption = Format(Vara, "$###,###.000")
End If

' if the Adjusted peak room count is less than Attendance
' then multiply aprc x 1.451 else, muliply attendance x 1.451

End Sub


RE: Newbie Question - Format in a Label

milin,
Try this:

Private Sub BtnCalc_Click()

Dim Vara 'Attendance entry
Dim Varprc 'Peak Room Count entry
Dim EI 'EI if Attendance and PRC are equal

'declare variables
Vara = Val(TxtAttend.Text) 'Attendance
Varprc = Val(TxtPRC.Text) ' Peak Room Count
EI = Vara * 1.451

If (Vara = Varprc) Then
LblEI.Caption = FormatCurrency(EI, 0) 'zero dec places

Else: Call BookingFormula1
End If
' If attendance and Peak Room Count are equal,
' there is a straight calculation -- the EI variable.
' If the values are not equal, BookingFormula1 is called
End Sub


Private Sub BookingFormula1()
Dim Vara ' Attendance from above
Dim Varprc& 'Peak Room Count from above
Dim XPrv ' adjusted Peak Room Count
Vara = Val(TxtAttend.Text) 'Attendance
Varprc = Val(TxtPRC.Text) 'Peak Room COunt
XPrv = Varprc * 1.8 'Adjusted Peak Room Count

If XPrv < Vara Then
XPrv = XPrv * 1.451
LblEI.Caption = FormatCurrency(XPrv, 0)
Else: Vara = Vara * 1.451
LblEI.Caption = FormatCurrency(Vara, 0)
End If

' if the Adjusted peak room count is less than Attendance
' then multiply aprc x 1.451 else, muliply attendance x 1.451

End Sub



RE: Newbie Question - Format in a Label

any time you output to the label

Label1.Caption = format(LocalVar, "currency")

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close