?
Solved

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

Posted on 2002-03-18
7
Medium Priority
?
154 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month13 days, left to enroll

777 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