Guus2005
AWF VIP
- Local time
- Today, 11:23
- Joined
- Jun 26, 2007
- Messages
- 2,642
In VB6 is used control array's to dynamically create controls on a form. Is that possible in VBA?
I want to be able to create a paint program in VBA. I want to load line controls to write or draw anything on a form. I found this code on www.planetsourcecode.com made by Niloy Mondal
Thx!
I want to be able to create a paint program in VBA. I want to load line controls to write or draw anything on a form. I found this code on www.planetsourcecode.com made by Niloy Mondal
Code:
'An control array of line has been made. Its visiblity is set to false.
Dim ButtonPress As Boolean
Dim lastx, lasty As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
ButtonPress = True
lastx = x
lasty = y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If ButtonPress = True Then
Load Line1(Line1.Count)
Line1(Line1.UBound).X1 = lastx
Line1(Line1.UBound).X2 = x
Line1(Line1.UBound).Y1 = lasty
Line1(Line1.UBound).Y2 = y
Line1(Line1.UBound).Visible = True
lastx = x
lasty = y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
ButtonPress = False
End Sub