Option Explicit
Private ObjOldWidth As Long '保存窗体的原始宽度
Private ObjOldHeight As Long '保存窗体的原始高度
Private ObjOldFont As Single '保存窗体的原始字体比
'在调用ResizeForm前先调用本函数
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
ObjOldWidth = FormName.ScaleWidth
ObjOldHeight = FormName.ScaleHeight
ObjOldFont = FormName.Font.Size / ObjOldHeight
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub
'按比例改变表单内各元件的大小,
'在调用ReSizeForm前先调用ReSizeInit函数
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim I As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / ObjOldWidth
'保存窗体宽度缩放比例
ScaleY = FormName.ScaleHeight / ObjOldHeight
'保存窗体高度缩放比例
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For I = 0 To 4
'读取控件的原始位置与大小
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(I) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(I) = 0
End If
On Error GoTo 0
End Sub
Private Sub Form_Resize()
'确保窗体改变时控件随之改变
Call ResizeForm(Me)
End Sub
Private Sub Form_Load()
Move (Screen.Width - Form2.Width) / 2, (Screen.Height - Form2.Height) / 2
Call ResizeInit(Me)
End Sub
Private Sub Option1_Click()
SSTab1.TabEnabled(4) = False
Text97.Enabled = False
Text98.Enabled = False
Text99.Enabled = False
End Sub
Private Sub Option2_Click()
SSTab1.TabEnabled(4) = True
Text97.Enabled = True
Text98.Enabled = True
Text99.Enabled = True
End Sub
Private Sub Command3_Click()
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
Text4.Text = 0
Text5.Text = 0
Text6.Text = 0 '清零
End Sub
Private Sub Command4_Click()
Text7.Text = 0
Text8.Text = 0
Text9.Text = 0
Text10.Text = 0
Text11.Text = 0
Text12.Text = 0 '清零
End Sub
Private Sub Command8_Click()
Form2.Hide
Form3.Show
End Sub
Private Sub Command9_Click()
End
End Sub
Private Sub Command7_Click()
Dim textobj As Control
For Each textobj In Controls
If TypeOf textobj Is TextBox Then
textobj.Text = ""
End If
Next
End Sub '清零文本框