M
Microsoft
I need to have two private subs have access to a variable. One will assign
the value and the second will use it.
The user will choose a file using the openfiledialog and a button
The user will use a second button to begin processing the file.
I can't seem to get the file name to move from sub to sub
First sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Browse.Click
Dim myStream As String
Dim filename As String
With findfile
..Title = "Pick file to open..."
..InitialDirectory() = "C:\"
..ShowDialog(Me)
End With
If findfile.ShowDialog() = DialogResult.OK Then
Dim FS As FileStream
FS = findfile.OpenFile
filename = FS.Name()
End If
Second sub which can'e see the filename variable and returns it as empty
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Stop
Dim subnet As String
Dim sr As StreamReader = New StreamReader(filename)
Dim line As String
'processing will occur here'
the value and the second will use it.
The user will choose a file using the openfiledialog and a button
The user will use a second button to begin processing the file.
I can't seem to get the file name to move from sub to sub
First sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Browse.Click
Dim myStream As String
Dim filename As String
With findfile
..Title = "Pick file to open..."
..InitialDirectory() = "C:\"
..ShowDialog(Me)
End With
If findfile.ShowDialog() = DialogResult.OK Then
Dim FS As FileStream
FS = findfile.OpenFile
filename = FS.Name()
End If
Second sub which can'e see the filename variable and returns it as empty
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Stop
Dim subnet As String
Dim sr As StreamReader = New StreamReader(filename)
Dim line As String
'processing will occur here'