Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Numbers in TextBox 1

Status
Not open for further replies.
Jun 12, 2003
25
US
I need to make one textbox display in scientific notation and a couple others have only 2 decimal places. The data is being brought in from excel. Does anyone know how to do this? Thanks!
 
Where is the data being brought into?



If you can't be "The Best", be the best at what you can!!!

Never say Never!!!
Nothing is impossible!!!
 
The text boxes are in a user form created using Visual Basic. I have already formatted the cells in excel but the formatting is lost in the textbox.
 
hey,
what format is the data in before it gets to the text box?
 
Hello,

the formatting in the textbox depends onhow you take the values from the sheet.

if you use
TextBox2.Value = Range("Aa6").Value
or
TextBox2.Value = Range("A6")
both of these will show the actual number, or magnitude in the box

but if you use
TextBox1.Value = Range("A6").Text
the text box will show the number exactly as it appears in the sheet, and not change the formatting.

Hope it helps :)
 
When you populate the TextBoxes use the following to:

'Format in Scientific format
TextBox1 = Format(TextBox1.Value, "Scientific")

'Format with 2 decimals
TextBox2 = Format(TextBox2.Value, "#,##0.00")

I hope this helps!


If you can't be "The Best", be the best at what you can!!!

Never say Never!!!
Nothing is impossible!!!
 
Thanks guys. I finally got it to work! This info is probably applicable to a lot of people so I'm going to give it a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top