Set MyRadioButton1 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")
Check the following example :
Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set MyRadioButton1 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")
Set MyRadioButton2 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
With Pos
.X = 90
.Y = 100
End With
With MyRadioButton1
.Location = Pos
.Text = "Option 1"
.Name = "optRadioButton1"
End With
With Pos
.X = 90
.Y = 130
End With
With MyRadioButton2
.Location = Pos
.Text = "Option 2"
.Name = "optRadioButton1"
End With
With Pos
.X = 90
.Y = 160
End With
With MyButton
.Location = Pos
.Text = "Close"
End With
With MyForm
.Controls.Add MyRadioButton1
.Controls.Add MyRadioButton2
.Controls.Add MyButton
.CancelButton = MyButton
.Text = "My Custom User Form"
.ShowDialog
End With
If MyRadioButton1.Checked Then
msgbox "You have selected - Option 1"
elseif MyRadioButton2.Checked then
msgbox "You have selected - Option 2"
else
msgbox "No Options Selected"
End If
Set MyRadioButton1 = Nothing
Set MyRadioButton2 = Nothing
Set Button = Nothing
Set Pos = Nothing
Set MyForm = Nothing
No comments:
Post a Comment