How can I open a file as FileStream in one Sub and then read bytes from the file with ReadByte in another Sub?
Here is the code I'm trying:
Private Sub btnGetfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetfile.Click
Path = txtFilename.Text
Dim fs As New FileStream(Path, FileMode.Open)
Dim br As New BinaryReader(fs)
Loc = 0
ShowBlock()
End Sub
Private Sub btnGoTo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGoTo.Click
Loc = txtGoTo.Text
ShowBlock()
End Sub
Private Sub ShowBlock()
Dim B As Byte
Dim L As Long
Try
For L = Loc To Loc+255
B = br.ReadByte
'
' use/process B here
'
Next L
Catch
Beep()
End Try
End Sub
The problem is that br is undefined in Sub ShowBlock.
How can I make br global?
Here is the code I'm trying:
Private Sub btnGetfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetfile.Click
Path = txtFilename.Text
Dim fs As New FileStream(Path, FileMode.Open)
Dim br As New BinaryReader(fs)
Loc = 0
ShowBlock()
End Sub
Private Sub btnGoTo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGoTo.Click
Loc = txtGoTo.Text
ShowBlock()
End Sub
Private Sub ShowBlock()
Dim B As Byte
Dim L As Long
Try
For L = Loc To Loc+255
B = br.ReadByte
'
' use/process B here
'
Next L
Catch
Beep()
End Try
End Sub
The problem is that br is undefined in Sub ShowBlock.
How can I make br global?