How to display output in monetary format

Lan Solo

Newcomer
Joined
May 28, 2003
Messages
15
Location
Alameda, CA
I am having trouble getting my output to display in monetary format. I have tried the System.ConvertTo method and convert ToString to no avail. So, I saved progress where it was still generating the proper math... just not in dollars. Any tips would be appreciated.

Here is what I have:

Code:
 Private lngNumberOfDays As Long
    Private intnudNumberOfGuests As Integer
    Private msglBaseRate As Single
    Private msglSubTotal As Single
    Private Const csglGuestSurcharge As Single = 10
    Private msglBedSurcharge As Single
    Private msglTotal As Single
    Private blnchkAdditionalBed As Boolean
    Private mdatStartDate As Date
    Private mdatEndDate As Date
    Private msglRadStandard As Single = "84.50"
    Private msglRadDeluxe As Single = "104.50"
    Private msglRadSuite As Single = "154.50"


    'This DateTimePicker selects guest arrival date

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStartDate.ValueChanged
        mdatStartDate = dtpStartDate.Value.Date
    End Sub

    'This DateTimePicker selects guest departure date

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpEndDate.ValueChanged
        mdatEndDate = dtpEndDate.Value.Date
    End Sub

    'nud determines number of guests

    Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudNumberOfGuests.ValueChanged
        
        If nudNumberOfGuests.Value > 2 Then
            txtGuestSurcharge.Text = nudNumberOfGuests.Value * csglGuestSurcharge
        End If

        If nudNumberOfGuests.Value <= 2 Then
            txtGuestSurcharge.Text = "0"
        End If

    End Sub

Thanks
 
Also you can try the FormatCurrency to display it in Monetary format, beware of this, it uses the options configured in your computer, so if in you country you use comma as the decimal separator and you have a dot configured, that is what will be displayed.
 
OK, I'm trying that but I am not sure where to put that code, or if I am using the proper syntax. The event handler now looks like:

Code:
 Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudNumberOfGuests.ValueChanged
        Format(txtGuestSurcharge.Text, "c")
        If nudNumberOfGuests.Value > 2 Then
            txtGuestSurcharge.Text = nudNumberOfGuests.Value * csglGuestSurcharge
        End If

        If nudNumberOfGuests.Value <= 2 Then
            txtGuestSurcharge.Text = "0"
        End If

    End Sub

Any suggestions?
 
Visual Basic:
 Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudNumberOfGuests.ValueChanged
        If nudNumberOfGuests.Value > 2 Then
            txtGuestSurcharge.Text = nudNumberOfGuests.Value * csglGuestSurcharge
        End If

        If nudNumberOfGuests.Value <= 2 Then
            txtGuestSurcharge.Text = "0"
        End If

        txtGuestSurcharge.Text = Format(txtGuestSurcharge.Text, "c")
    End Sub
 
Back
Top