Visual Basic Help..
Wed Feb 11 2009, 10:00 pm
Need help Please
This is the code that i wrote..
it basically works like this:
1.VB will receive 10 digit number from serial port
2.Then the 10 digit number will be compared to the existing database
3.If match it will sent character "o" to serial port (to PIC) and save the data to new database in VB
4.If not match it will sent character "f" to serial port (to PIC).
i Know that VB will read code line by line. the problem is when the 10 digit not match it also sent character "o" (suppose it will sent only character "f")
What happen here is when ID not match it will sent both "o" and "f"
i hope anybody can help me...Thank You
This is the code that i wrote..
Private Sub MSComm1_OnComm() Dim vntBookmark As Variant Dim Achar As String Achar = MSComm1.Input Aline = Aline & Achar Text_TagID.Text = Aline If Len(Aline) = 10 Then With Student_Database.Recordset vntBookmark = .Bookmark .MoveFirst .Find "Tag Like " & Aline & "" End With LogBook.Recordset.AddNew LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text LogBook.Recordset.Fields("Name") = Text_Name.Text LogBook.Recordset.Fields("IC Number") = Text_IC.Text LogBook.Recordset.Fields("Matric Number") = Text_Matric.Text LogBook.Recordset.Fields("Plat Number") = Text_Plate.Text LogBook.Recordset.Fields("Time") = timeLable.Caption LogBook.Recordset.Fields("Date") = dateLable.Caption LogBook.Recordset.Update Aline = "" With MSComm2 If .PortOpen = False Then .CommPort = 4 .Settings = "9600,n,8,1" .RThreshold = 1 .RTSEnable = True .InputLen = 1 .PortOpen = True End If End With MSComm2.Output = "o" If Student_Database.Recordset.EOF Then ' MsgBox "Tag Not found", vbCritical, "RFID Tag" Student_Database.Recordset.Bookmark = vntBookmark LogBook.Recordset.Fields("Name") = "Not Registered" LogBook.Recordset.Fields("IC Number") = "Not Registered" LogBook.Recordset.Fields("Matric Number") = "Not Registered" LogBook.Recordset.Fields("Plat Number") = "Not Registered" With MSComm2 If .PortOpen = False Then .CommPort = 4 .Settings = "9600,n,8,1" .RThreshold = 1 .RTSEnable = True .InputLen = 1 .PortOpen = True End If End With MSComm2.Output = "f" End If End If End Sub
it basically works like this:
1.VB will receive 10 digit number from serial port
2.Then the 10 digit number will be compared to the existing database
3.If match it will sent character "o" to serial port (to PIC) and save the data to new database in VB
4.If not match it will sent character "f" to serial port (to PIC).
i Know that VB will read code line by line. the problem is when the 10 digit not match it also sent character "o" (suppose it will sent only character "f")
What happen here is when ID not match it will sent both "o" and "f"
i hope anybody can help me...Thank You
[ Edited Thu Feb 12 2009, 02:39 am ]
Powered by e107 Forum System