Velocity Reviews > Convert Unit types.

# Convert Unit types.

Ken Varn
Guest
Posts: n/a

 10-19-2004
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
-----------------------------------

WALDO
Guest
Posts: n/a

 10-26-2004
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
Guest
Posts: n/a

 10-26-2004
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!

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Heidy UK VOIP 1 06-22-2007 09:53 AM VvanN C++ 5 04-28-2006 10:01 AM OCZ Guy DVD Video 6 08-01-2004 05:44 PM OCZ Guy Computer Information 0 07-31-2004 12:29 PM