Private Sub Button12_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Dim Checkboxno As String
Dim Checkitem As String
Dim finfo As New FileInfo("D:\CountOutput.txt")
Dim dur As StreamReader = finfo.OpenText
Dim count As Integer
While dur.Peek > 0
dur.ReadLine()
count += 1
End While
dur = finfo.OpenText
While dur.Peek > 0
If count <= +2 Then
Checkboxno &= dur.ReadLine & " "
Checkboxno = Mid(Checkboxno, 19, 11)
Label21.Visible = True
Label21.Text = TextBox1.Text
Else
dur.ReadLine()
End If
count -= 1
End While
If TextBox1.Text = "" Then
MessageBox.Show(" กรุณาใส่เลขกล่อง ")
ElseIf TextBox1.Text <> Checkboxno Then
MessageBox.Show(" กรุณาใส่เลขกล่องให้ถูกต้อง ")
End If
End Sub
Tag : .NET, Win (Windows App), VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
dim A As Boolean
dim B As Boolean
if source.IndexOf("คำค้น1") < 0
then A = False
else A = True
end if
if source.IndexOf("คำค้น2") < 0
then B = False
else B = True
end if
if (A=True) and (B=True)
then
....
end if
Dim fileinfo As New System.IO.FileStream("D:\CountOutput.txt", IO.FileMode.Open)
Dim Reader As New System.IO.StreamReader(fileinfo)
Dim List As New List(Of String)
Do While Reader.Peek > 0
List.Add(Reader.ReadLine)
Loop
Dim Array1 As String() = List.ToArray
fileinfo.Close()
Reader.Close()
fileinfo = New System.IO.FileStream("D:\CountOutput.txt", IO.FileMode.Open)
Reader = New System.IO.StreamReader(fileinfo)
Dim sArray As String()
Dim Index As Integer
Do While Reader.Peek > 0
ReDim Preserve sArray(Index)
sArray(Index) = Reader.ReadLine
Index += 1
Loop
Dim i As Integer
For i = 0 To UBound(sArray)
Label20.Visible = True
Label20.Text = sArray(i)
Next
fileinfo.Close()
Reader.Close()
End Sub
Dim fileinfo = New System.IO.FileStream("D:\CountOutput.txt", IO.FileMode.Open)
Dim Reader = New System.IO.StreamReader(fileinfo)
Dim sArray As String()
Dim Index As Integer
Dim tmp As String
Do While Reader.Peek > 0
tmp = Reader.ReadLine;
if tmp.IndexOf("คำค้น1") >= 0
then
begin
ReDim Preserve sArray(Index)
sArray(Index) = tmp
Index += 1
end
end if
Loop
Dim i As Integer
Dim c As Integer = sArray.Length-1;
For i = 0 To c
Label20.Visible = True
Label20.Text = sArray(i)
Next
fileinfo.Close()
Reader.Close()
Dim strRegex as String = "(สแกนยังไม่ครบ\s?Box\s?G\d{4}/\d{5}\s?\d{2}/\d{3})" //หรือ "(.*?Box\s?G\d{4}/\d{5}\s?\d{2}/\d{3})"
Dim myRegex As New Regex(strRegex, RegexOptions.None)
Dim strTargetString As String = My.Computer.FileSystem.ReadAllText("D:\CountOutput.txt",System.Text.Encoding.UTF32)
For Each myMatch As Match In myRegex.Matches(strTargetString)
messagebox.show(myMatch.Group[1].Value)
Next