Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

 


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

Posted
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.
Fat kids are harder to kidnap
Posted

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:

 


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?

Posted
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

Code today gone tomorrow!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...