Drag And Drop

TUTORIAL RFID Reader Device in VB.Net

View previous topic View next topic Go down

TUTORIAL RFID Reader Device in VB.Net

Post by DND-OMZ on Sun Jul 26, 2015 6:40 pm

First open your Visual Studio (any version) and create New Project.

Second ADD the following object to your form.
1. One SerialPort
2. One TextBox
3. One ListBox

Setup your SerialPort
1. BaudRate = 9600
2. DataBit = 8
3. DiscardNull = False
4. DtrEnable = False
5. HandShake = None
6. Parity = None
7. ParityRepalce = 63
8. PortName = check your com port name ether COM1 or Any but make sure your com name is correct
9. ReadBufferSize = 4096
10. RtsEnable = False
11. StopBit = One
12. WriteBufferSize = 2048



Code:


Public Class Form1
Dim data as string = nothing

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        System.Windows.Forms.Control.CheckForïllêgâlCrossThreadCalls = False
End Sub

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        data = data + SerialPort1.ReadExisting() ' Need to read existing data to clean all pending data
        If Len(data) > 16 Then
            SerialPort1.DtrEnable = False
            TextBox1.Text = Microsoft.VisualBasic.Mid(data, 2, 12)
            Dim li As ListBox.ObjectCollection
            li = ListBox1.Items

            If Not li.Contains(TextBox1.Text) Then
                ListBox1.Items.Add(Microsoft.VisualBasic.Mid(data, 2, 12))
                Beep()
            End If
          
            Dim delay As DateTimeOffset = Now.AddMilliseconds(1500)

            Do
                Application.DoEvents()
            Loop Until Now > delay

            data = SerialPort1.ReadExisting()
            SerialPort1.DiscardInBuffer()
            data = String.Empty
            SerialPort1.DtrEnable = True

        End If
End Sub

End Class



Now you need an RFID Reader Device and Tag Card, Press F5 and start debugging
make sure the cursor is point into TextBox1... Top your Tag Card to the device and you see the tag card data on list box.

Hope this help happy happy coding... Very Happy


-OMZ
avatar
DND-OMZ
Admin

Posts : 4
Points : 12
Reputation : 0
Join date : 2015-07-26
Age : 23
Location : Urdaneta City, Pangasinan

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum