Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB4: Format a numeric textbox to Currency without using convert

Status
Not open for further replies.

Dayman

Programmer
Jan 17, 2000
2
AU
Hope someone can help. I am creating an accounting package and need to have textboxes display automatically in Currency with decimals.<br>
<br>
Thanks
 
SOLUTION FOUND AS FOLLOWS:<br>
<br>
Module:<br>
<br>
' Convert any value into currency format. If the<br>
' value does not make sense, return 0.00.<br>
Public Function cvCur(ByVal Value As Variant) As Currency<br>
On Error Resume Next<br>
cvCur = CCur(Value)<br>
If Err.Number &lt;&gt; 0 Then cvCur = 0<br>
End Function<br>
<br>
In the textbox requiring the Currency put the following code:<br>
<br>
Private Sub txtCurrency_Change()<br>
txtCurrency.Text = Format$(cvCur(txtCurrency.Text), &quot;Currency&quot;)<br>
<br>
End Sub<br>
<br>
I hope this code is of help to somebody. I know I couldn't find it anywhere on the web at all.<br>
<br>
Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top