
เท่าที่ดู Code พบว่าการนำค่า Value ใน TextBox ไปตรวจสอบกับ String ใน ListBox ไม่สามารถใช้ได้
เพราะค่าใน TextBox ถูกเปลี่ยนไปจากการคลิกเลือกของ User แล้ว ดังนั้น การตรวจสอบ
จึงต้องตรวจกับค่าของ String ใน ListBox เอง เทียบกับค่าที่สามารถจะเป็นไปได้ทั้งหมด โดยเขียน Code
Extract Value ใน String ออกมาเอง
ลองปรับใช้ตัวอย่าง Code ตามด้านล่างและตามไฟล์แนบครับ
Code: Select all
Private Sub Start_botton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start_botton.Click
Dim a As Object = 0 'Set ไว้สำหรับเปรียบเทียบ ค่าจาก Listbox
Dim s As String
Dim t As String = "0123456789"
Dim i As Integer
'On Error Resume Next
For Each a In Command_list.Items
s = ""
For i = 1 To Len(a)
If InStr(t, Mid(a, i, 1)) > 0 Then
s = s & Mid(a, i, 1)
End If
Next
'If a = " Syringe UP : " + CStr(Volume) + " µL" Then
If Mid(a, 1, 14) = " Syringe UP : " And Mid(a, Len(a) - 2, 3) = " µL" Then
MsgBox(Mid(a, Len(a) - 2, 3))
SerialPort1.Write("U")
MessageBox.Show("UP")
SerialPort1.Write(s)
MessageBox.Show(s)
SerialPort1.Write("E")
MessageBox.Show("E")
'///////////////////////// UP //////////////////////////////////
'ElseIf a = " Syringe Down : " + CStr(Volume) + " µL" Then
ElseIf Mid(a, 1, 16) = " Syringe Down : " And Mid(a, Len(a) - 2, 3) = " µL" Then
SerialPort1.Write("D")
MessageBox.Show("Down")
SerialPort1.Write(CStr(Volume))
MessageBox.Show(Volume)
SerialPort1.Write("E")
MessageBox.Show("E")
'//////////////////////////////// DOWN ////////////////////////////
'ElseIf a = " Syringe Swing : " + CStr(cycle) + " cycle" Then
ElseIf Mid(a, 1, 17) = " Syringe Swing : " And Mid(a, Len(a) - 5, 6) = " cycle" Then
SerialPort1.Write("G")
MessageBox.Show("Swing")
SerialPort1.Write(CStr(cycle))
MessageBox.Show(cycle)
SerialPort1.Write("E")
MessageBox.Show("E")
'/////////////////////////////// Swing ////////////////////////////////
ElseIf a = " Selection valve : Water" Then
SerialPort1.Write("W")
MessageBox.Show("Water")
'///////////////////////////// Water ///////////////////////////////////
ElseIf a = " Selection valve : Solution1" Then
SerialPort1.Write("S")
MessageBox.Show("Solution1")
'//////////////////////////// Solution1 /////////////////////////////////
End If
Next
SerialPort1.Write("C")
MessageBox.Show("Complete")
End Sub
You do not have the required permissions to view the files attached to this post.