|
-
Jul 3rd, 2023, 04:54 PM
#1
Thread Starter
Fanatic Member
Two Controls, One Event
Hi guys! its gaouser again, I was experimenting with the ScriptControl and managed a way to use dim withevents and .move () The scriptcontrol is at form1, the code i posted under is at form2, I .addobject the form2 to script control with members true, But after creating 2 buttons and 2 events, Only last button has event, I cant fix 
I created this code:
Code:
Dim WithEvents button As VB.CommandButton
Private Sub button_Click()
Form1.ScriptControl1.Run (button.name & "_click")
End Sub
Sub moveobject(ByVal controlname As String, ByVal x As Integer, ByVal y As Integer)
Dim targetControl As Control
Set targetControl = Me.Controls(controlname)
' Check if the control with the given name exists
If Not targetControl Is Nothing Then
' Set the position of the control
targetControl.Left = x
targetControl.Top = y
Else
' Control with the given name does not exist
MsgBox "Control with name " & controlname & " does not exist."
End If
End Sub
Sub addbutton(ByVal name As String)
Set button = Controls.Add("VB.CommandButton", name, Form2)
button.Visible = True
End Sub
Private Sub Form_Load()
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|