Solved

Syntax for FormatCurrency

Posted on 2006-07-21
5
866 Views
Last Modified: 2012-08-13
This is Excel VBA
I have this piece of code I need to add

FormatCurrency to this line in the code
(TextBox2.Text = rng(.ListIndex + 1, 3)

What would be the proper syntax?

Any help would greatly be appreciated

/////////////////////////////////////////////////////////
With ComboBox1
        Set rng = Range(.RowSource)
        TextBox1.Text = rng(.ListIndex + 1, 2)
       (TextBox2.Text = rng(.ListIndex + 1, 3)        
     End With
0
Comment
Question by:ca1358
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17155321
In Excel VBA you can use CCur(value) to convert any value to a currency $#,###.## format.
0
 

Author Comment

by:ca1358
ID: 17156172
Sorry,  I should have told you it is a UserForm.

0
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 500 total points
ID: 17159971
Dim curOne As Currency
Dim curTwo As Currency

For i = LBound(ComboBox1.Count) To UBound(ComboBox1.Count - 1)

With ComboBox1
        Set rng = Range(.RowSource)
        curOne = Format(rng(.ListIndex + 1, i) , Currency)       '< --- here
        curTwo = Format(rng(.ListIndex + 1, i), Currency)        '< ---- and here
TextBox1.Text = curOne
TextBox2.Text = curTwo
End With

Next

something like that maybe ? If not then just get rid of the for next loop and replace the i is above with the 2 and 3 you had originally

Hopefully this helps anyway ( With regards to the format function, here is a reference )

http://msdn2.microsoft.com/en-us/library/y006s0cz.aspx

If you need more help post back

0
 

Author Comment

by:ca1358
ID: 17170919
Thank you!
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 17171129
np - hopefully it worked for you ( I was just wrote the code out from memory )
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 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…

708 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

19 Experts available now in Live!

Get 1:1 Help Now