Private Sub Command3_Click()
With CommonDialog1
.DialogTitle = "Open Text File"
.CancelError = False
.Filter = "Text Files (*.cfg*)|*.cfg*"
.ShowOpen
If Len(CommonDialog1.FileName) = 0 Then
Exit Sub
End If
sFile = CommonDialog1.FileName
End With
End Sub
' แล้วเอาข้อมูลมาใส่ตรงนี้
Open "ไฟล์ที่ดึงมา" For Append As #1
Print #1, "username" & Space(2) & Text1.Text & Space(2) & "confirm"
Close #1
End
จขกท เรียก Part มาได้แล้วใช้ไหมครับ
จขกท สามารถเรียกใช้งาน ไฟล์ได้จาก Class FileStream,StreamReader,StreamWriter ครับ
ตัวอย่างก็
OP.Filter = "Text Files | *.txt"
OP.FileName = ""
If OP.ShowDialog = Windows.Forms.DialogResult.OK Then
_File = New FileStream(OP.FileName, LBoxFileMode.SelectedItem, LboxFileAccress.SelectedItem)
Dim _Read As StreamReader
_Read = New StreamReader(_File, System.Text.UnicodeEncoding.Default)
Rbox.Text = _Read.ReadToEnd
_Read.Close()
_File.Close()
End If
OP.Filter = "Config (*.cfg*)|*.cfg*"
OP.FileName = ""
If OP.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim _File as FileStream
_File = New FileStream(OP.FileName, LBoxFileMode.SelectedItem, LboxFileAccress.SelectedItem)
Dim _Read As StreamReader
_Read = New StreamReader(_File, System.Text.UnicodeEncoding.Default)
Rbox.Text = _Read.ReadToEnd
Dim _Writer As StreamWriter
_Writer =New StreamWriter(_File,??????????)
Rbox.Text=_Writer.Writer
_Writer.Close()
_Read.Close()
_File.Close()
End If
OP.Filter = "Text Files | *.txt"
OP.FileName = ""
If OP.ShowDialog = Windows.Forms.DialogResult.OK Then
_File = New FileStream(OP.FileName, LBoxFileMode.SelectedItem, LboxFileAccress.SelectedItem)
Dim _Read As StreamReader
_Read = New StreamReader(_File, System.Text.UnicodeEncoding.Default)
Rbox.Text = _Read.ReadToEnd
_Read.Close()
_File.Close()
End If