Ron,
In the DisableButton2 method you are creating a new instance of Form1 and
disabling the button on this new instance. When the DisableButton2 method
ends this new instance of Form1 is distroyed.
Change your DisableButton2 method to look something like:
Public Sub DisableButton2( byval aForm as Form1)
aForm.Button2.Enabled=False
End Sub
And change the call to this method to be something like:
DisableButton2(Me)
This will send the DisableButton2 method a reference to the instance of
Form1 you are seeing on the display and onwhich you are clicking the button.
-Sam Matzen
"Ron Dahl" <rd***@ghp.com> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
I have created a project with a form called form1 and a module called
module1.
Form1 contains two buttons, button1 and button1.
The event code for button1 is:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DisableButton2()
End Sub
The procedure code in module1 is:
Public Sub DisableButton2()
Dim MyForm As Form1 = New Form1
MyForm.Button2.Enabled = False
End Sub
This code does not disable button1 and there is no error message.
What am I doing wrong?
Thanks in advance for any help.
Ron Dahl