vb生成的界面随电脑分辨率变化方法,下面的程序为热心网友提供,但是运行时提示“编译异常:未找到数据或方法
vb生成的界面随电脑分辨率变化方法,下面的程序为热心网友提供,但是运行时提示“编译错误:未找到数据或方法
Public Sub chang(ThisForm As Form)
Dim DesignX As Integer
Dim DesignY As Integer
Dim XFactor As Single
Dim YFactor As Single
Dim X As Integer
DesignX% = 1400: DesignY% = 900
XFactor = (Screen.Width / Screen.TwipsPerPixe1X) / DesignX
YFactor = (Screen.Height / Screen.TwipsPerPixe1Y) / DesignY
If XFactor = 1 And YFactor = 1 Then
Exit Sub
With ThisForm
.Move .Left * XFactor, .Top * YFactor, .Width * XFactor, .Height * YFactor
For X = 0 To .Controls.Count - 1
If TypeOf .Controls(X) Is DriveListBox Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
ElseIf TypeOf .Controls(X) Is ComboBox Then
If T.Controls(X).Style <> 1 Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
End If
Else
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor, .Controls(X).Height * YFactor
If TypeOf .Controls(X) Is TextBox Then
.Controls(X).FontSize = .Controls(X).FontSize * XFactor
ElseIf TypeOf .Controls(X) Is Label Then
.Contr ols(X).FontSize = .Controls(X).FontSize * XFactor
End If
End If
Next X
End With
End Sub
引用是这样的:
Public Sub chang(ThisForm As Form)
Dim DesignX As Integer
Dim DesignY As Integer
Dim XFactor As Single
Dim YFactor As Single
Dim X As Integer
DesignX% = 1400: DesignY% = 900
XFactor = (Screen.Width / Screen.TwipsPerPixe1X) / DesignX
YFactor = (Screen.Height / Screen.TwipsPerPixe1Y) / DesignY
If XFactor = 1 And YFactor = 1 Then
Exit Sub
With ThisForm
.Move .Left * XFactor, .Top * YFactor, .Width * XFactor, .Height * YFactor
For X = 0 To .Controls.Count - 1
If TypeOf .Controls(X) Is DriveListBox Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
ElseIf TypeOf .Controls(X) Is ComboBox Then
If T.Controls(X).Style <> 1 Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
End If
Else
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor, .Controls(X).Height * YFactor
If TypeOf .Controls(X) Is TextBox Then
.Controls(X).FontSize = .Controls(X).FontSize * XFactor
ElseIf TypeOf .Controls(X) Is Label Then
.Contr ols(X).FontSize = .Controls(X).FontSize * XFactor
End If
End If
Next X
End With
End Sub
引用是这样的: