Dim Ctl As Control
' 记录每个 Control 的原始位置、大小、字型大小, 放在 Tag 属性中
On Error Resume Next '确保left, top, width, height, Tag属性没有全有的Control
For Each Ctl In Me '也能正常执行
Ctl.Tag = Ctl.Left & " " & Ctl.Top & " " & Ctl.Width & " " & Ctl.Height & " "
Ctl.Tag = Ctl.Tag & Ctl.FontSize & " "
Next Ctl
flxGridhistory.Cols = 2
flxGridhistory.FormatString = "^类别|^信息"
For I = 0 To flxGridhistory.Cols - 1
flxGridhistory.ColWidth(I) = flxGridhistory.Width / 2 - 150
Next I
On Error GoTo 0
End Sub
Private Sub Form_Resize()
Dim D(4) As Double
Dim I As Long
Dim TempPos As Long
Dim StartPos As Long
Dim Ctl As Control
Dim TempVisible As Boolean
Dim ScaleX As Double
Dim ScaleY As Double
ScaleX = ScaleWidth / InitWidth
ScaleY = ScaleHeight / InitHeight
On Error Resume Next
For Each Ctl In Me
TempVisible = Ctl.Visible
Ctl.Visible = False
StartPos = 1
' 读取 Control 的原始位置、大小、字型大小
For I = 0 To 4
TempPos = InStr(StartPos, Ctl.Tag, " ", vbTextCompare)
If TempPos > 0 Then
D(I) = Mid(Ctl.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
D(I) = 0
End If
' 根据比例设定 Control 的位置、大小、字型大小
Ctl.Move D(0) * ScaleX, D(1) * ScaleY, D(2) * ScaleX, D(3) * ScaleY
'Ctl.Width = D(2) * ScaleX
'Ctl.Height = D(3) * ScaleY
If ScaleX < ScaleY Then
Ctl.FontSize = D(4) * ScaleX
Else
Ctl.FontSize = D(4) * ScaleY
End If
Next I
Ctl.Visible = TempVisible
Next Ctl
On Error GoTo 0
For I = 0 To frmDengjiStart.flxGridhistory.Cols - 1
frmDengjiStart.flxGridhistory.ColWidth(I) = frmDengjiStart.flxGridhistory.Width / 2 - 150
Next I
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim I As Integer
For I = Forms.Count - 1 To 1 Step -1
Unload Forms(I)
Next
rs.Close
Set rs = Nothing
rs1.Close
Set rs1 = Nothing
db.Close
Set db = Nothing
End Sub
二.出租登记界面设计:
出租界面代码设计:
Private Sub Command1_Click()
Dim j
rs.Edit
If frmdengjicuzu.Caption = "出租登记窗口" Then
For j = 0 To rs.Fields.Count - 1
If rs.Fields(j).Name = "使用权权属人" Then
rs.Fields(j) = Text2.Text
End If