comma function for textbox

Hi,

Please assist how can we create a sub that will change the data inside a textbox to place a comma, like how the currency works?

i.e.
Text1.Text=350000
CommaText(Text1.Text,True)

Result:
Text1.Text=350,000

CommaText(textbox name, True to place comma or False to remove comma)

Thanks.
RyanBankAsked:
Who is Participating?
 
cquinnConnect With a Mentor Commented:
Function CommaText(sValue as string, bToggle as boolean) as String

if bToggle then
  CommaText=Format(sValue, "##,##0")  
else
  CommaText=Format(sValue, "####0")  
end if

End Function
0
 
RyanBankAuthor Commented:
Will that also work if the value was more than a thousand? 1,000,000
0
 
dancebertConnect With a Mentor Commented:
Works on any size input:
? Format(10000000000000000, "##,##0")  
10,000,000,000,000,000
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.