Solved

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

Posted on 2002-03-18
7
148 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
  • 3
  • 3
7 Comments
 
LVL 1

Author Comment

by:Ege
ID: 6879185
In Addition:

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

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 49

Accepted Solution

by:
Ryan Chong earned 150 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 49

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now