Option Explicit
'Declare variables
Dim CX As Integer
Dim CY As Integer
Dim sngAspect As Single
Dim intRadius As Integer
Private Sub Command1_Click()
'Calculate the aspect ratio
sngAspect = HScroll1.Value / VScroll1.Value
'Clear the form
Me.Cls
'Reset the scroll bar values
HScroll1.Value = 200
VScroll1.Value = 200
'Draw the circle/ellipse
Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub
Private Sub Form_Load()
'Reset the scroll bar values
HScroll1.Value = 200
VScroll1.Value = 200
End Sub
Private Sub Form_Resize()
'If the form is not minimized resize all object to fit on the form
If Me.WindowState <> 1 Then
'Move the command button
Command1.Move Me.ScaleWidth - 15, Me.ScaleHeight - 15, 15, 15
'Move the scroll bars
HScroll1.Move 0, Me.ScaleHeight - 15, Me.ScaleWidth - 15, 15
VScroll1.Move Me.ScaleWidth - 15, 0, 15, Me.ScaleHeight - 15
'Recalculate the center of the circle
CX = Me.ScaleWidth / 2 - VScroll1.Width
CY = Me.ScaleHeight / 2 - HScroll1.Height
'Calculate the radius of the circle
If CX > CY Then
intRadius = CX / 2
Else
intRadius = CY / 2
End If
End If
End Sub
Private Sub HScroll1_Change()
'Reset the vertical scroll bar
VScroll1.Value = 200
'Recalculate the aspect ratio
sngAspect = HScroll1.Value / VScroll1.Value
'Clear the form
Me.Cls
'Redraw the circle/ellipse
Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub
Private Sub VScroll1_Change()
'Reset the horizontal scroll bar
HScroll1.Value = 200
'Recalculate the aspect ratio
sngAspect = HScroll1.Value / VScroll1.Value
'Clear the form
Me.Cls
'Redraw the circle/ellipse
Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub