• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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.
0
RyanBank
Asked:
RyanBank
2 Solutions
 
cquinnCommented:
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
 
dancebertCommented:
Works on any size input:
? Format(10000000000000000, "##,##0")  
10,000,000,000,000,000
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now