# Convert Unit types.

Discussion in 'ASP .Net Web Controls' started by Ken Varn, Oct 19, 2004.

1. ### Ken VarnGuest

Can someone explain how to convert a Unit type to a meaningful value? There
is a way to convert from a Pixel, Percent, etc.. to a Unit, but I have not
figured out how to convert from a Unit.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Ken Varn, Oct 19, 2004

2. ### WALDOGuest

The Unit structure is merely there to convert those unit types into
strings for web controls. There is no math involved in this structure.

If you want to do conversions, you'll have to write your own conversion
functions.

Off the top of my head, I think it's:
72 points/inch (I could be wrong)
96 pixels/inch (I could be wrong)
You can convert percent to pixels and vice-versa if you know the width
in pixels of whatever its contained in. (10% of a 400px container is
40px)

Sometimes the greatest solutions come from the simplest logic.
Being told no is merely the incentive to do it anyway.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

WALDO, Oct 26, 2004

3. ### WALDOGuest

There are also the Type and Value Properties on the Unit Structure. For
Example:

Dim u As Unit = Unit.Parse("17px")
'u.Value = 17
'u.Type = Pixel

Sometimes the greatest solutions come from the simplest logic.
Being told no is merely the incentive to do it anyway.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

WALDO, Oct 26, 2004