ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox format (https://www.excelbanter.com/excel-programming/381922-textbox-format.html)

Oggy

Textbox format
 
Hi

I have the following code to pick up infomation from the spreadsheet
and show it in my userform.


Dim text1 As Long

text1 = UserForm6.TextBox1.Value

Range("A4").Select
Set material1 = Selection

material1.Value = text1

If the number on the spreadsheet is to 2 decimal places the result is
rounded, ie 2.72 is shown as 3.

Any suggestions to resolve the problem will be gratfully recieved.

Regards

Oggy


Jim Cone

Textbox format
 
Oggy,
Change the data type of text1 from Long to Double.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Oggy"
wrote in message
Hi
I have the following code to pick up infomation from the spreadsheet
and show it in my userform.

Dim text1 As Long

text1 = UserForm6.TextBox1.Value

Range("A4").Select
Set material1 = Selection

material1.Value = text1

If the number on the spreadsheet is to 2 decimal places the result is
rounded, ie 2.72 is shown as 3.
Any suggestions to resolve the problem will be gratfully recieved.
Regards
Oggy


Jim Thomlinson

Textbox format
 
you have declared text 1 as long (Long Integer) which will force an implicit
conversion of your decimal to an integer. Change the declaration to double

Dim text1 as double
--
HTH...

Jim Thomlinson


"Oggy" wrote:

Hi

I have the following code to pick up infomation from the spreadsheet
and show it in my userform.


Dim text1 As Long

text1 = UserForm6.TextBox1.Value

Range("A4").Select
Set material1 = Selection

material1.Value = text1

If the number on the spreadsheet is to 2 decimal places the result is
rounded, ie 2.72 is shown as 3.

Any suggestions to resolve the problem will be gratfully recieved.

Regards

Oggy




All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com