2010_S2_Phillips_Scott_HH_1

=__**Scott Phillip's Handy Hint #1:**__=

When working with currency you generally can't put in a "$" sign within a text field since it's counted as a String instead of an Integer/Single/Double etc.

However, when a text field has been locked so the user can't touch it in any way (such as in a calculator), theres a neat little trick you can do to show a "$" both before and after the user inputs any data for calculation.

Example: Try Dim AccNumber As Integer = Integer .Parse(txtAccNumber.Text) Dim StartBalance As Integer = Integer .Parse(txtStartBalance.Text) Dim Charges As Integer = Integer .Parse(txtCharges.Text) Dim Credits As Integer = Integer .Parse(txtCredits.Text) Dim NewBalance As Integer

NewBalance = (StartBalance - Charges) + Credits Me .txtNewBalance.Text = NewBalance.ToString //' txtNewBalance.Clear// //txtNewBalance.Text = Format(NewBalance, "$0.00" )//

' Down here with the format function you can change the way the number appears. Such as with a "$" sign. ' Alternatively, if you wish to show the "$" sign before data has even been calculated, in the properties window under Text by inserting a "$". ' You can then add "theTextFieldName".Clear such as shown above before the calculation to clear the field before it reads the String and errors, _ ' ($ being the string)

Catch ex As System.Exception MessageBox.Show( "There were Blank or Non-numeric data that was inputted.", "Blank or Non-numeric" , MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try