Lan Solo Posted June 13, 2003 Posted June 13, 2003 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 Quote
iebidan Posted June 13, 2003 Posted June 13, 2003 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. Quote Fat kids are harder to kidnap
Lan Solo Posted June 13, 2003 Author Posted June 13, 2003 Thanks folks. How do I learn the syntax for the format function? Quote
*Gurus* divil Posted June 13, 2003 *Gurus* Posted June 13, 2003 You type Format and press F1. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Lan Solo Posted June 13, 2003 Author Posted June 13, 2003 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? Quote
a_jam_sandwich Posted June 13, 2003 Posted June 13, 2003 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 Quote Code today gone tomorrow!
Lan Solo Posted June 13, 2003 Author Posted June 13, 2003 Thanks for the help everyone. Bit by bit I'm gettin' this. "You must unlearn what you have learned." -Yoda Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.