Ok well Your question wasn't really clear to me but I did what I "THINK" you were getting at. I'm assuming that you are using
VB.NET so Here's what I did:
Create a project with 2 forms, "FORM1" and "FORM2"
Create a Module called "MODULE1"
Put this is module1:
'Create an instance of form2
Public frmTwo as new Form2
THATS it for module1 now in the Form1_Load event put:
frmTwo.Show
AND in the form1, Button1_Click event put:
frmTwo.Text = "HELLO THERE!!!"
frmTwo.Button1.Enabled = False
When you start the program forms 1 and 2 will be displayed on the screen when you click Button1 on form1 the Text Property of form2 is changed and the button on form2 is disabled. In VB6 you used to be able to access controls on another form by just preceeding the control name with the form name. But in
VB.NET you have to create an instance of the second form and then use the instance to access controls on the second form...here is the entire code:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(208, 116)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(516, 418)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
frmTwo.Text = "Hello There!"
frmTwo.Button1.Enabled = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
frmTwo.Show()
End Sub
End Class
Module Module1
Public frmTwo As New Form2
End Module
Tim
Uber Development God
[email protected]