
Passing as string variable from sub to sub
Hi Armon,
There are a few ways to share data between sub / method calls depending on
what you want to do.
The easiest thing you can do is to define the shared variable in a place
that is in scope to both subs. Usually you do not want to modify the
parameters that an event handler (such as pgmlabel.Click) is expecting.
E.g.
Dim s1path As String = ""
Private Sub Mach1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Mach1.Click
s1path = "C:\cncmgr\m1pg\"
End Sub
Private Sub pgmlabel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles pgmlabel.Click
Dim localpath As String = s1path
End Sub
You could also define the path in a new Module file if you want it to be
available to all forms in the app:
Module Module1
Public myPath As String = "C:\cncmgr\m1pg\"
End Module
If this does not solve the problem, please tell me a little more about what
you want to do on this form, and how you want each event handler sub to use
the path.
Best,
Paul
Visual Basic .NET
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Quote:
> How do you pass a string variable from one sub to another.
> Private Sub Mach1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Mach1.Click
> Dim s1path As String = "C:\cncmgr\m1pg\"
> End Sub
> Private Sub pgmlabel_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs, ByVal s1path As String) Handles pgmlabel.Click
> ERROR GENERATED
> Method 'pgmlabel_Click' cannot handle Event 'Click' because they do not
have
> the same signature.
> I need to pass the variable "s1path"
> These subs are in the form design stage.
> Thanks for any help