I'm trying to open a specified text file without having the program to open a dialog. how should I do it? The error is highlighted in red.
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Windows form generated codes
Private Sub btnSelectPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectPicture.Click
Dim myStream As Stream
Dim openFileDialog1 As New OpenFileDialog
If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1("\Program Files\GPS.txt")
C:\Documents and Settings\user\My Documents\Visual Studio Projects\openfile\Form1.vb(82): Class 'System.Windows.Forms.OpenFileDialog' cannot be indexed because it has no default property.
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close()
End If
End If
End Sub
Private Sub binQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Me.Close()
End Sub
End Class
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Windows form generated codes
Private Sub btnSelectPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectPicture.Click
Dim myStream As Stream
Dim openFileDialog1 As New OpenFileDialog
If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1("\Program Files\GPS.txt")
C:\Documents and Settings\user\My Documents\Visual Studio Projects\openfile\Form1.vb(82): Class 'System.Windows.Forms.OpenFileDialog' cannot be indexed because it has no default property.
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close()
End If
End If
End Sub
Private Sub binQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Me.Close()
End Sub
End Class