如何按百分比计算screenLeft和screenTop?

时间:2018-01-23 14:18:23

标签: vb.net web

我可以使用screenLeftscreenTop获取窗口的X和Y坐标。
但是,我需要将像素值转换为百分比。这样做的公式是什么?

我在vb.net中为宽度和高度转换做了这个,

Dim widthpix As Integer = CType(sItems(0), Integer)
Dim heighpix As Integer = CType(sItems(1), Integer)
widthinpercent = CInt((widthpix / PrimaryScreen.Bounds.Width) * 100)
heightinpercent = CInt((heighpix / PrimaryScreen.Bounds.Height)*100)

以百分比形式转换window.screenLeftwindow.screenTop的公式是什么?

1 个答案:

答案 0 :(得分:0)

尝试:

Dim widthinpercent As Integer = CInt((Me.Location.X / Screen.PrimaryScreen.Bounds.Width) * 100)
Dim heightinpercent As Integer = CInt((Me.Location.Y / Screen.PrimaryScreen.Bounds.Height) * 100)
MsgBox(" X =" & widthinpercent.ToString() & "% | Y =" & heightinpercent.ToString() & "%")