Hello All,
I'm trying to iterate over the frames on a form in my form_resize event to resize them with the form. Here's my code. What am I doing wrong? Thanks in advance!
Private Sub Form_Resize()
'Variables
Dim fra As Frame
Dim MinHeight As Long
Dim MinWidth As Long
'I've actually got these next two lines in form_load
MinHeight = Me.Height
MinWidth = Me.Width
'Check to see if form's getting too
'small forcing a min height and width
If Me.WindowState = vbMinimized Then Exit Sub 'Avoid error-NO resize if minimized
If MinHeight > frmMain.Height Then
frmMain.Height = MinHeight
Exit Sub
ElseIf MinWidth > frmMain.Width Then
frmMain.Width = MinWidth
Exit Sub
End If
On Error Resume Next
For Each fra In frmMain
If fra.Visible = True Then
fra.Top = 10
fra.Left = 0
fra.Width = frmMain.ScaleWidth
fra.Height = frmMain.Height - 1200
End If
Next
End Sub
Any help would be greatly appreciated. fra doesn't seem to be set or assigned to anything during For Each, therefore the if statement is skipped....I think.
I'm trying to iterate over the frames on a form in my form_resize event to resize them with the form. Here's my code. What am I doing wrong? Thanks in advance!
Private Sub Form_Resize()
'Variables
Dim fra As Frame
Dim MinHeight As Long
Dim MinWidth As Long
'I've actually got these next two lines in form_load
MinHeight = Me.Height
MinWidth = Me.Width
'Check to see if form's getting too
'small forcing a min height and width
If Me.WindowState = vbMinimized Then Exit Sub 'Avoid error-NO resize if minimized
If MinHeight > frmMain.Height Then
frmMain.Height = MinHeight
Exit Sub
ElseIf MinWidth > frmMain.Width Then
frmMain.Width = MinWidth
Exit Sub
End If
On Error Resume Next
For Each fra In frmMain
If fra.Visible = True Then
fra.Top = 10
fra.Left = 0
fra.Width = frmMain.ScaleWidth
fra.Height = frmMain.Height - 1200
End If
Next
End Sub
Any help would be greatly appreciated. fra doesn't seem to be set or assigned to anything during For Each, therefore the if statement is skipped....I think.