0

So I have a main form and 5 other forms. When I press a button on the main form, I want it to open Form2 and disable a certain button in form2 so that it cannot be used. I produced this code but the button is still active and there is no effect. Please help.

 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        My.Forms.Form2.SaveVISACaseButton.Enabled = False
        My.Forms.Form2.SaveVISACaseButton.Visible = False
        Dim form2 As New Form2
        My.Forms.Form2.SaveVISACaseButton.Enabled = False
        My.Forms.Form2.SaveVISACaseButton.Visible = False
        form2.Show()
        Me.Hide()

    End Sub
3
Contributors
2
Replies
7
Views
4 Years
Discussion Span
Last Post by Jx_Man
Featured Replies
  • 1

    Declare object instance of form2 and use it to disable or visble a button in form2. You already declare it but you didn't use it. Try this : Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim form2 As New Form2 form2.SaveVISACaseButton.Enabled = False form2.SaveVISACaseButton.Visible = False form2.Show() … Read More

0

It appears to me that if Form2 is already designed that you won't need to Dim a new one just show the one you have.

1

Declare object instance of form2 and use it to disable or visble a button in form2.
You already declare it but you didn't use it.
Try this :

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim form2 As New Form2
    form2.SaveVISACaseButton.Enabled = False
    form2.SaveVISACaseButton.Visible = False
    form2.Show()
    Me.Hide()
End Sub
Comments
Nice.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.