VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



formatcurrency

by Vikramjit Singh (4 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (38 Votes)

format a text field into a $ currency field.

Inputs
text box name
Assumes
Call teh module by passing any text box name that you want to have as a currency text box.
Code 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)

Rate formatcurrency

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

Download this snippet    Add to My Saved Code

formatcurrency Comments

No comments have been posted about formatcurrency. Why not be the first to post a comment about formatcurrency.

Post your comment

Subject:
Message:
0/1000 characters