Private Sub BTCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTCheck.Click
Dim iSum As Integer = 0
Dim variableGoodCode As String
'*** Open Database
conn = GetConnect()
conn.Open()
'*** Check Good-Code
For iSum = 0 To DataGridView1.RowCount - 2
variableGoodCode = DataGridView1.Rows(iSum).Cells("docuno").Value
strSQL = "SELECT * FROM SOHD WHERE DocuNo = '" & variableGoodCode & "'"
dtAdapter = New SqlDataAdapter(strSQL, conn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
'*** เมื่อพบในฐานข้อมูล
Else
'*** msgbox ประกาศตัวแปร Docuno ที่ไม่พบในฐานข้อมูล
MsgBox(variableGoodCode)
End If
Next
End Sub