VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Pixels to Twips


Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This converts pixels to twips

Inputs
# of Pixels or twips
Assumes
This converts pixels to twips, if you get the rect of a window it's in pixels, to make your form that size you need to convert the pixels to twips. As someone pointed out in one of my other submisions, it might be a little faster to take away the function and just use the insides where needed but i find the function saves some typing and makes the code easier to read.
Code Returns
# of pixels or twips... see code

Rate Pixels to Twips

Function PixelsToTwips_height(pxls)
PixelsToTwips_height = pxls * screen.TwipsPerPixelY
end function
Function PixelsToTwips_width(pxls)
PixelsToTwips_width = pxls * screen.TwipsPerPixelX
end function
'This next part reverses the las although you should
'be able to use basic math
Function TwipsToPixels_height(pxls)
PixelsToTwips_height = pxls \ screen.TwipsPerPixelY
end function
Function TwipsToPixels_width(pxls)
PixelsToTwips_width = pxls \ screen.TwipsPerPixelX
end function

Download this snippet    Add to My Saved Code

Pixels to Twips Comments

No comments have been posted about Pixels to Twips. Why not be the first to post a comment about Pixels to Twips.

Post your comment

Subject:
Message:
0/1000 characters