‘###################################################################################
‘UTILITY OBJECTS – D O T N E T F A C T O R Y
‘###################################################################################
Description:
To create an instance of a .NET object, and access its methods and properties. We can create forms where the user can interact with them and give some input in run time
Public Function funcDotNetFactory()
‘Creating Objects
Set objMainForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set objTextField = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set objButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set objPosition = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
‘Assigning Text Field Co-ordinates
objPosition.X = 150
objPosition.Y = 150
objTextField.Location = objPosition
objTextField.Width = 100
'Assigning Button Details
objPosition.X = 130
objPosition.Y = 130
objButton.Location = objPosition
objButton.Text = "Close"
'Adding Text Field and Button to Main Form
objMainForm.Controls.Add objTextField
objMainForm.Controls.Add objButton
objMainForm.CancelButton = objButton
'Show Form
objMainForm.ShowDialog
‘Un-Initializing the Variables
Set objTextField = Nothing
Set objButton = Nothing
Set objPosition = Nothing
Set objMainForm = Nothing
End Function
‘###################################################################################
No comments:
Post a Comment