formatcurrency

By | 2002-06-01

format a text field into a $ currency field.

Original Author: Vikramjit Singh

Inputs

text box name

Assumptions

Call teh module by passing any text box name that you want to have as a currency text box.

Returns

formatted value in $

API Declarations

‘put as many text boxes as you want…say text1
‘call the class by using the following line
Call validate(Text1)

Code

Sub validate(textboxname As TextBox)
If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then
KeyAscii = 0
End If
mypos = InStr(1, textboxname.Text, ".")
If mypos <> 0 Then
textboxname.Text = Format(textboxname.Text, "$###,###,###,###.##")
Else
textboxname.Text = Format(textboxname.Text, "$###,###,###,###")
End If
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.