Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how can I change an entered currenct number from integer to comma seperated?

Posted on 2002-03-18
7
Medium Priority
?
156 Views
Last Modified: 2010-05-02
Hi,

I need in Visual Basic that,
I want to change the display of a curreny entered by user, automatically to comma seperated one.

Sample:
A field. User enters the numbers and I need to change it comma seperated with respect to it's .000 ones.
Steps      User Entered     Screen Out
=====      ============     ==========
Step 1:     1               1
Step 2:     12              12
Step 3:     120             120
Step 4:     1200            1,200
Step 5:     12000           12,000
Step 6:     120000          120,000
Step 7:     1200000         1,200,000
..... and so on...
??
thanx for your interest...
0
Comment
Question by:Ege
[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
  • 3
7 Comments
 
LVL 1

Author Comment

by:Ege
ID: 6879185
In Addition:

it will be done whenever onChange property...
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6879192
Hi Ege,

Use the Format function in VB:

Dim iCur As Currency
iCur = 12532.646

Debug.Print Format$(iCur,"#,##0.00")

Cheers
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 450 total points
ID: 6879197
Use this if needed:

Public Sub CheckCurrency(ByVal txtControl As TextBox)
    txtControl = Trim$(txtControl)
    If Not IsNumeric(txtControl) Or Val(txtControl) < 0 Then
        txtControl = txtControl.Tag
    Else
        txtControl = Format(txtControl, "#,##0.00")
        txtControl.Tag = txtControl
    End If
End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Ege
ID: 6879223
Himmm, I never use Format fot this purpose..

One more thing,
To change a currency, 1255650 to 1,255,650 (not .00)

Debug.Print Format$(iCur,"#,##0") is ok?
  or
Debug.Print Format$(iCur,"#,###") ?

What is the main idea of #,### here?
if number is too big, with 12 digits for example,
do I need to increase number of #'s?

I will increase the point...


0
 
LVL 2

Expert Comment

by:ronenr
ID: 6879244
No, the # is only to represent the format and not the number of digits, so format(number,"#,###") indicates that every 3 numbers will be a comma.

Good luck
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6879250
Yes, you can try: Debug.Print Format$(iCur,"#,##0"), it will remove the decimal place.

Use Debug.Print Format$(iCur,"#,##0") if you want to display 0 when a value is smaller than 0.

Use Debug.Print Format$(iCur,"#,###") will display nothing.

Use 0 is like placing the value with 0
0
 
LVL 1

Author Comment

by:Ege
ID: 6879264
Thanx for your all interest...
Best regards...
ryancys has been accepted... I works... Please answer my other question about adding two larg, very big number, grater than LONG...

bye
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

618 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