VB Converting Excel % Values to Decimal 
Author Message
 VB Converting Excel % Values to Decimal

I have a application acting as an interface for an excel spreadsheet. I have
values coming to text boxes from excel cells (using active x). Some cells
have % values in them, when I take them across to VB using

Text2.Text = XlSheet.Range("A20").Value

the % value is converted to a decimal so i.e. a value of 90% appears in the
text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
"90%" to be returned but a string of "90" would be okay also. I've tried
using the data format property but this does no good. any ideas would be
cool.

cheers,
dave.



Sat, 08 May 2004 22:08:23 GMT  
 VB Converting Excel % Values to Decimal
I have a application acting as an interface for an excel spreadsheet. I have
values coming to text boxes from excel cells (using active x). Some cells
have % values in them, when I take them across to VB using

Text2.Text = XlSheet.Range("A20").Value

the % value is converted to a decimal so i.e. a value of 90% appears in the
text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
"90%" to be returned but a string of "90" would be okay also. I've tried
using the data format property but this does no good. any ideas would be
cool.

cheers,
dave.



Sat, 08 May 2004 22:05:04 GMT  
 VB Converting Excel % Values to Decimal
On Tue, 20 Nov 2001 14:05:04 -0000, "Dave Hammond"

Quote:

>I have a application acting as an interface for an excel spreadsheet. I have
>values coming to text boxes from excel cells (using active x). Some cells
>have % values in them, when I take them across to VB using

>Text2.Text = XlSheet.Range("A20").Value

>the % value is converted to a decimal so i.e. a value of 90% appears in the
>text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
>"90%" to be returned but a string of "90" would be okay also. I've tried
>using the data format property but this does no good. any ideas would be
>cool.

>cheers,
>dave.

Change your code as follows:

Text2.Text = format(XlSheet.Range("A20").Value,"percent")

All numerical numbers are stored in a spreadsheet in their native
format.  What you see on the screen is all a matter of formatting.
Percentages are stored as a decimal and formatted as a percentage
within the spreadsheet.

Stuart Sutherland



Sun, 09 May 2004 03:24:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting large hex values to decimal

2. Converting fraction string to a decimal value

3. Convert decimal comma to decimal point

4. Convert Decimal to Binary,Binary to Decimal VB4

5. Converting C++ Hexadecimal Values to VB Hexadecimal Values.

6. converting decimal to binary in vb

7. Convert HEX to DECIMAL in VB 4.0

8. inserting decimal values (ADO 2.6,ORACLE 8,VB 6 sp4)

9. How can I convert this Excel VB code to Access VB

10. Converting Currency Values to their string values

11. Converting Long color value to RGB values

12. convert a value to words expressing the value

 

 
Powered by phpBB® Forum Software