Dim ItemList As New ArrayList()
Private Sub TestString_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ItemList.Add("10B^17034209^1BA")
ItemList.Add("01^1703380B9^20A")
ItemList.Add("0B^17033809^20A")
ItemList.Add("02^17033809^20BA")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For i = 0 To ItemList.Count - 1
Dim item As String = ItemList.Item(i)
For j = 0 To item.Length - 1
If item.Substring(j, 1) = "B" Then
'หาตำแหน่งของ B
ListBox1.Items.Add("ชุดที่ " & i & " ตำแหน่งของ B คือ " & j)
End If
Next
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
For i = 0 To ItemList.Count - 1
Dim item As String = ItemList.Item(i)
For j = 0 To item.Length - 1
'เอาเฉพาะ "B"
If item.Substring(j, 1) = "B" Then
ListBox2.Items.Add("ค่า " & item.Substring(j, 1) & " ของชุดข้อมูล " & ItemList.Item(i))
End If
Next
Next
End Sub