โดยดัดแปลงจากโค๊ดเดิมที่อ่านเรียงลำดับไฟล์ตาม Text File ดังนี้คะ
Code (VB.NET)
Dim strPath As String = "\Barcode\List\barcodelist.txt"
If Txtinput.Text.Trim = "" Then
MessageBox.Show(" Please Input Bar Code ")
Else
'*** Write Text file ***/
Dim StrWer As StreamWriter = Nothing
StrWer = New StreamWriter(strPath, True)
StrWer.WriteLine(Me.Txtinput.Text + "|" + Me.Lbldate.Text + " " + Me.Lbltime.Text)
StrWer.Close()
Me.Txtinput.Text = ""
Lbldate.Text = dtNow.Date
MessageBox.Show("Write Text Successful", "Write Text", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Txtlist.Text = ""
'*** Read Text file ***/
Dim StrRer As StreamReader
Dim strLine As String
StrRer = File.OpenText(strPath)
While Not (StrRer.EndOfStream)
strLine = StrRer.ReadLine().ToString()
Me.Txtlist.Text() += strLine & vbCr & vbLf
End While
StrRer.Close()
End If
ขอบคุณล่วงหน้าคะ
Tag : .NET, Win (Windows App), Device (Mobile), VS 2005 (.NET 2.x)
Private Sub readText()
Dim strPath As String = "Test.txt"
If IO.File.Exists(strPath) Then
Dim StrRer As New IO.StreamReader(strPath)
Dim listStr As New List(Of String)
Do Until StrRer.EndOfStream
listStr.Add(StrRer.ReadLine())
Loop
Txtlist.Text = String.Empty
For i As Integer = listStr.Count - 1 To 0 Step -1
Txtlist.Text &= listStr(i) & vbCrLf
Next
Else
MsgBox("ไม่เจอ Test.txt")
End If
End Sub