Discussion in "Software" started by    alifamir    Feb 11, 2009.
Wed Feb 11 2009, 10:00 pm
#1
Need help Please

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 ]
Fri Feb 27 2009, 05:52 am
#2
It ok...a have found the solution...thanks ........

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Sazrfci
Sun Oct 06 2024, 06:33 am
Sazrzhk
Sun Oct 06 2024, 01:34 am
Sazrjgz
Sun Oct 06 2024, 01:23 am
Dnrthvf
Sat Oct 05 2024, 08:39 pm
Dnrthwo
Sat Oct 05 2024, 08:27 pm
Mofredka
Sat Oct 05 2024, 03:43 pm
ErnestClagS
Sat Oct 05 2024, 06:44 am
Arisha4Et
Fri Oct 04 2024, 05:53 pm