Solved

comma function for textbox

Posted on 2006-07-20
3
294 Views
Last Modified: 2010-05-18
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
Comment
Question by:RyanBank
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
cquinn earned 450 total points
ID: 17146795
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
 

Author Comment

by:RyanBank
ID: 17146831
Will that also work if the value was more than a thousand? 1,000,000
0
 
LVL 9

Assisted Solution

by:dancebert
dancebert earned 50 total points
ID: 17147014
Works on any size input:
? Format(10000000000000000, "##,##0")  
10,000,000,000,000,000
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question