I would like to open my .txt file, but i get this error
Error 1 ‘Open’ is not declared. File I/O functionality is normally available in the ‘Microsoft.VisualBasic’ namespace, but the targeted platform does not support it.
I’m using vb2010 and I think the code is wrong cuz it’s for vb6. How to change it to work in vb2010?
Private Sub zapisz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zapisz.Click
Open "C:\Plik.txt" For Append As #1 'zapis
print #1, "a" & a.Text
Print #1, "b" & b.Text
Print #1, "c" & c.Text
Print #1, "d" & d.Text
Close #1
End Sub
Private Sub wczytaj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wczytaj.Click
Dim strText As String, strIndex As String
Open "C:\Plik.txt" For Input As #1
Do Until EOF(1)
Input #1, strText
strIndex = Left(strText, 1)
strText = Right(strText, Len(strText) - 1)
Select Case strIndex
Case "a" : a = strText
Case "b" : b = strText
Case "c" : c = strText
Case "d" : d = strText
End Select
Loop
Close #1
End Sub
The tools in the .NET framework make this sort of thing much cleaner and intuitive than the old VB6 file access statements: