N
Nozza
I want to be able to use a variable in a program to select one of many
controls - labels - on a form, and make the control visible or not.
But I can't seem to get this to work.
I seem to be going around in circles, and there is something I am not
getting.
If I have a form named Form 1, and with a label, and a button on it, I
can enter the following code
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim MyString As String = "Form1.Label1"
Call MakeInVisible(MyString)
End Sub
Sub MakeInVisible(ByVal PassedString As String)
Dim MyControl As New Control
MyControl.Name = PassedString
MyControl.Visible = False
End Sub
End Class
I can run the program, but the control named Label1 does not have its
visible property changed
The point of the program above is for me to work out how to pass a
variable to a parameter of a procedure, and then in the procedure use
the parameter to identify a control and then adjust the proerties of
the control. I know in the example above I could just enter a command
Form1.Label1.Visible = False without the need to call a procedure
Any help gratefully received.
Noz
controls - labels - on a form, and make the control visible or not.
But I can't seem to get this to work.
I seem to be going around in circles, and there is something I am not
getting.
If I have a form named Form 1, and with a label, and a button on it, I
can enter the following code
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim MyString As String = "Form1.Label1"
Call MakeInVisible(MyString)
End Sub
Sub MakeInVisible(ByVal PassedString As String)
Dim MyControl As New Control
MyControl.Name = PassedString
MyControl.Visible = False
End Sub
End Class
I can run the program, but the control named Label1 does not have its
visible property changed
The point of the program above is for me to work out how to pass a
variable to a parameter of a procedure, and then in the procedure use
the parameter to identify a control and then adjust the proerties of
the control. I know in the example above I could just enter a command
Form1.Label1.Visible = False without the need to call a procedure
Any help gratefully received.
Noz