Results 1 to 24 of 24

Thread: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Resolved [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    hello there..

    can anybody help me to do my task here, i want to connecting my RFID reader and VB6, so i can obtain and retrieve the rfid tag in message box on vb6. and this is my code so far, but i dont know why it doesnt work, plz help me.

    Private Sub MSComm1_OnComm()
    Dim data As String
    data = MSComm1.Input
    Text5.Text = Text5.Text & data
    Text8.Text = Text8.Text & data
    If cari = True Then
    If Text7.Text = Text8.Text Then
    MsgBox "buku ditemukan", , "save"
    cari = False
    Command5.Enabled = True
    End If
    End If

    anyway i use simple RF ID called id-12 and use pasive tag.
    thnx beforehand.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Retrieve & Obtain RFID Tag with VB6

    Have you tried searching the forum for "RFID VB6"?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    allready, sir.
    but most of them are designed for VB 2005 or higher, kind a confuse here..

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    Are you sure you're using the correct COM port number? I suspect the device is connected via USB which is emulating a SerialPort
    Have you made sure that the Speed, Data Bits, Start Bits, Stop Bits and Parity settings are correct ?
    Have you Opened the Port OK?

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    Are you sure you're using the correct COM port number? I suspect the device is connected via USB which is emulating a SerialPort
    Have you made sure that the Speed, Data Bits, Start Bits, Stop Bits and Parity settings are correct ?
    Have you Opened the Port OK?
    yes sir, i use some converter (serial to usb).
    heres the setting 9600,n,8,1 commport:1 handshaking:0
    actually that setting i got from books that talk about show rfid tag in vb6, plz correct me if im wrong.

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    My guess is that the COMport is incorrect. You should be able to see which COM port(s) are available from Device Manager

  7. #7

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    My guess is that the COMport is incorrect. You should be able to see which COM port(s) are available from Device Manager
    hm.. anyway, i allready try some thread on this forum, and try that source too,
    here it goes :
    Option Explicit

    Private Sub Form_Load()
    MSComm1.CommPort = 1
    MSComm1.Settings = 9600
    MSComm1.RThreshold = 8
    MSComm1.InputMode = comInputModeBinary
    MSComm1.PortOpen = True
    End Sub

    Private Sub MSComm1_OnComm()
    If MSComm1.CommEvent = comEvReceive Then
    Dim InBuffer
    Dim DimensionedByteArray(7) As Byte ' Can handle up to 8 Bytes
    Dim intCount As Integer
    Dim intDecimal As Integer
    InBuffer = MSComm1.Input

    For intCount = 0 To (LenB(InBuffer) - 1)
    DimensionedByteArray(intCount) = CByte(InBuffer(intCount))
    intDecimal = DimensionedByteArray(intCount)
    Text1.Text = Text1.Text & " " & intDecimal ' Display Decimal number
    Next intCount
    Debug.Print TypeName(intDecimal) ' Confirm InBuffer data is Integer
    End If
    End Sub

    on link http://www.vbforums.com/showthread.p...=1#post3376664

    but the output is

    in text1.text shows 2 53 53 48 48 51 66 57

    with eror msg :
    runtime eror : 9
    subscript out of range

    => DimensionedByteArray(intCount) = CByte(InBuffer(intCount))

    is there any solution?
    thnx beforehand

  8. #8
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    |You could try this
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    MSComm1.CommPort = 1
    MSComm1.Settings = 9600
    MSComm1.RThreshold = 1
    MSComm1.PortOpen = True
    End Sub
    
    Private Sub MSComm1_OnComm()
    Dim InBuffer
    Dim DimensionedByteArray() As Byte ' Can handle up to 8 Bytes
    Dim intCount As Integer
    Dim intDecimal As Integer
    If MSComm1.CommEvent = comEvReceive Then
        InBuffer = MSComm1.Input
        ReDim DimensionedByteArray(LenB(InBuffer) - 1)
        For intCount = 0 To (LenB(InBuffer) - 1)
            DimensionedByteArray(intCount) = CByte(InBuffer(intCount))
            intDecimal = DimensionedByteArray(intCount)
            Text1.Text = Text1.Text & " " & intDecimal & "(" & Chr(intDecimal) & ")" ' Display Decimal number and character it represents
        Next intCount
    End If
    End Sub

  9. #9

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    |You could try this
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    MSComm1.CommPort = 1
    MSComm1.Settings = 9600
    MSComm1.RThreshold = 1
    MSComm1.PortOpen = True
    End Sub
    
    Private Sub MSComm1_OnComm()
    Dim InBuffer
    Dim DimensionedByteArray() As Byte ' Can handle up to 8 Bytes
    Dim intCount As Integer
    Dim intDecimal As Integer
    If MSComm1.CommEvent = comEvReceive Then
        InBuffer = MSComm1.Input
        ReDim DimensionedByteArray(LenB(InBuffer) - 1)
        For intCount = 0 To (LenB(InBuffer) - 1)
            DimensionedByteArray(intCount) = CByte(InBuffer(intCount))
            intDecimal = DimensionedByteArray(intCount)
            Text1.Text = Text1.Text & " " & intDecimal & "(" & Chr(intDecimal) & ")" ' Display Decimal number and character it represents
        Next intCount
    End If
    End Sub
    thnx again sir for your support so far, but it still give some eror.

    run-time eror '13':
    type mismatch

    especially on code :
    => DimensionedByteArray(intCount) = CByte(InBuffer(intCount))

  10. #10
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    Try changing
    Code:
        ReDim DimensionedByteArray(LenB(InBuffer) - 1)
        For intCount = 0 To (LenB(InBuffer) - 1)
    to
    Code:
        ReDim DimensionedByteArray(Len(InBuffer) - 1)
        For intCount = 0 To (Len(InBuffer) - 1)

  11. #11

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    Try changing
    Code:
        ReDim DimensionedByteArray(LenB(InBuffer) - 1)
        For intCount = 0 To (LenB(InBuffer) - 1)
    to
    Code:
        ReDim DimensionedByteArray(Len(InBuffer) - 1)
        For intCount = 0 To (Len(InBuffer) - 1)
    still the same eror, Sir.
    actually this rfid kit come with delphi source that can retrieve the card/tag id.
    but i wanna try to make it on VB6.
    here it goes,
    Code:
    unit RFID;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, CPort, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Label1: TLabel;
        ComboBox1: TComboBox;
        Label2: TLabel;
        ComPort1: TComPort;
        Memo1: TMemo;
        Button1: TButton;
        ComDataPacket1: TComDataPacket;
        Timer1: TTimer;
        procedure FormShow(Sender: TObject);
        procedure ComPort1RxChar(Sender: TObject; Count: Integer);
        function hextoint(input : string):longint;
    //    procedure StopTesSer;
        procedure ComboBox1Change(Sender: TObject);
    //    procedure Button1Click(Sender: TObject);
    //    procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      data : byte;
      counter : byte;
      check_sum,nomor : string;
      flag_equ : boolean;
      sent, recv : byte;
    
    implementation
    
    {$R *.DFM}
    
    function tform1.hextoint(input : string):longint;
    var
        c,i : longint;
        input1 : string;
    begin
        c:=0;
        input1:='';
        for i:=length(input) downto 1 do input1:=input1+input[i]+'';
        input1:=uppercase(input1);
        for i:=1 to length(input1) do
        begin
          if (input1[i] in ['A'..'F'])and(i>1)then
              c:=((ord(input1[i])-ord('A')+10) shl (4*(i-1)))or c
          else
          if (input1[i] in ['0'..'9'])and(i>1)then
              c:=((ord(input1[i])-ord('0')) shl (4*(i-1))) or c
          else
          if (input1[i] in ['A'..'F'])and(i=1)then
              c:=(ord(input1[i])-ord('A')+10) or c
          else
          if (input1[i] in ['0'..'9'])and(i=1)then
              c:=(ord(input1[i])-ord('0')) or c;
        end;
        result:=c;
    end;
    
    procedure TForm1.FormShow(Sender: TObject);
    begin
      combobox1.ItemIndex:=0;
      comport1.Close;
      comport1.Port:=combobox1.Items.Strings[0];
      comport1.Open;
      nomor:='';
      check_sum:='';
      counter:=0;
      memo1.clear;
    {  timer1.Enabled:=false;
      timer1.interval:=25;
      button1.caption:='Tes Serial';}
    end;
    
    procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
    var i : integer;
    begin
    //  if button1.caption='Tes Serial' then
        for i:=0 to count do
        begin
          comport1.Read(data,1);
          inc(counter);
          case counter of
          1:
            if data = 2 then
            begin
              memo1.Clear;
              memo1.lines.add('Start OK');
            end
            else
            begin
              nomor:='';
              check_sum:='';
              counter:=0;
            end;
          12,13:
            begin
              check_sum:=check_sum+chr(data);
              memo1.lines.add('Checksum '+inttostr(counter-12)+' = '+inttohex(data,2));
            end;
          16:
            begin
              if data = 3 then
              begin
                label1.caption:='Nomor Kartu : '+inttostr(hextoint(nomor));
                memo1.lines.add('End Data');
              end
              else
                memo1.lines.add('End Data Invalid');
              nomor:='';
              check_sum:='';
              counter:=0;
            end;
          4..11:
            begin
              nomor:=nomor+chr(data);
              memo1.lines.add('Data ke '+inttostr(counter-4)+' = '+inttohex(data,2));
            end;
          end;
          sleep(50);
          application.ProcessMessages;
        end;
    end;
    
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
      comport1.Close;
      comport1.Port:=combobox1.Items.Strings[combobox1.ItemIndex];
      comport1.Open;
    end;
    
    {procedure TForm1.Button1Click(Sender: TObject);
    begin
      if button1.caption='Tes Serial' then
      begin
        button1.caption:='Stop Tes';
        combobox1.Enabled:=false;
        memo1.clear;
        flag_equ:=true;
        sent:=0;
        comport1.clearbuffer(true,false); // clear COM input buffer
        comport1.write(sent,1);
        timer1.Enabled:=true;
        end
      else
        StopTesSer;
    end;}
    
    {procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      comport1.read(recv,1);
      if recv<>sent then flag_equ:=false;
      memo1.lines.add(inttostr(sent)+' = '+inttostr(recv));
      if sent>=63 then
        StopTesSer
      else
      begin
        Inc(sent);
        Comport1.Write(sent,1);
      end;
    end;}
    
    {Procedure Tform1.StopTesSer;
    begin
      Button1.Caption:='Tes Serial';
      Timer1.Enabled:=False;
      Combobox1.Enabled:=True;
      if Flag_Equ then
        Memo1.Lines.Add('Tes serial : BAIK')
      else
        Memo1.Lines.Add('Tes serial : GAGAL');
      comport1.clearbuffer(true,false); // clear COM input buffer
    end;}
    
    end.

  12. #12
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    I know zero squared about Delphi but it looks as if the protocol is something like this:

    Byte 1 = Hex 02 (STX)
    Bytes 2 & 3 seem to be ignored
    Bytes 4 to 11 The Data
    Bytes 12 & 13 Checksum
    Bytes 14 & 15 seem to be ignored
    Byte 16 - Hex 03 (ETX)

    You may get away with using a String Buffer which in some cases is easier to manage than Byte Arrays:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    MSComm1.CommPort = 1
    MSComm1.Settings = 9600
    MSComm1.RThreshold = 1
    MSComm1.PortOpen = True
    End Sub
    
    Private Sub MSComm1_OnComm()
    Static strBuffer As String
    Dim strData As String
    Dim binComplete As Boolean
    Dim intI As Integer
    Select Case MSComm1.CommEvent
        Case comEvReceive
            strData = MSComm1.Input
            strBuffer = strBuffer & strData
            Do
                If Len(strBuffer) >= 16 Then
                    If Asc(Mid$(strBuffer, 1, 1)) = 2 Then
                        Text1.Text = Text1.Text & "Start OK" & vbNewLine
                        Text1.Text = Text1.Text & "Data:" & vbNewLine
                        For intI = 4 To 11
                            Text1.Text = Text1.Text & CStr(intI - 4) & " = "
                            Text1.Text = Text1.Text & " Hex: " & Hex(Asc(Mid$(strBuffer, intI, 1)))
                            Text1.Text = Text1.Text & " Char: " & Mid$(strBuffer, intI, 1) & vbNewLine
                        Next intI
                        Text1.Text = Text1.Text & "Checksum:" & vbNewLine
                        For intI = 12 To 13
                            Text1.Text = Text1.Text & Hex(Asc(Mid$(strBuffer, intI, 1)))
                        Next intI
                        Text1.Text = Text1.Text & vbNewLine
                        If Asc(Mid$(strBuffer, 15, 1)) = 3 Then
                            Text1.Text = Text1.Text & "End OK" & vbNewLine
                        Else
                           Text1.Text = Text1.Text & "Synchronisation Error - ETX not received" & vbNewLine
                           Text1.Text = Text1.Text & "Expected ETX, received: " & Hex(Asc(Mid$(strBuffer, 15, 1))) & vbNewLine
                        End If
                    Else
                        Text1.Text = Text1.Text & "Synchronisation Error - STX not received" & vbNewLine
                        Text1.Text = Text1.Text & "Expected STX, received: " & Hex(Asc(Mid$(strBuffer, 1, 1))) & vbNewLine
                    End If
                    If Len(strBuffer) > 16 Then
                        strBuffer = Mid$(strBuffer, 17)
                    Else
                        binComplete = True
                        strBuffer = ""
                    End If
                Else
                    binComplete = True
                End If
            Loop Until binComplete
    End Select
    End Sub
    The above should emulate the Delphi code in terms of functionality. Note that the TextBox, text1, should have its MultiLine property set to True and ScrollBars are advised.

    Obviously the above is not tested so there may be a gremlin or two lurking around

    EDIT: Regarding the Delphi Code, I can't work out the reason for the Timer. It appears that clicking on the Button sends a zero to the device and starts the timer. The timer triggers every 25mS, perform a read from the device and checks if what's been received is equal to what was sent. It then sends the value of a counter to the device, starting at 1, and increments the counter. It does this 63 times and then stops the timer. That logic is not included in the above. Have you got any documentation regarding the operation of the device ?
    Last edited by Doogle; Jul 29th, 2013 at 01:24 AM.

  13. #13
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Retrieve & Obtain RFID Tag with VB6

    cataztrophe, thanks for the PM but there is nothing that I can give you that Doogle couldn't do better.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  14. #14

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    I know zero squared about Delphi but it looks as if the protocol is something like this:

    Byte 1 = Hex 02 (STX)
    Bytes 2 & 3 seem to be ignored
    Bytes 4 to 11 The Data
    Bytes 12 & 13 Checksum
    Bytes 14 & 15 seem to be ignored
    Byte 16 - Hex 03 (ETX)

    You may get away with using a String Buffer which in some cases is easier to manage than Byte Arrays:
    Code:
    
    
    The above should emulate the Delphi code in terms of functionality. Note that the TextBox, text1, should have its MultiLine property set to True and ScrollBars are advised.

    Obviously the above is not tested so there may be a gremlin or two lurking around

    EDIT: Regarding the Delphi Code, I can't work out the reason for the Timer. It appears that clicking on the Button sends a zero to the device and starts the timer. The timer triggers every 25mS, perform a read from the device and checks if what's been received is equal to what was sent. It then sends the value of a counter to the device, starting at 1, and increments the counter. It does this 63 times and then stops the timer. That logic is not included in the above. Have you got any documentation regarding the operation of the device ?

    Start OK
    Data:
    0 = Hex: 30 Char: 0
    1 = Hex: 30 Char: 0
    2 = Hex: 37 Char: 7
    3 = Hex: 39 Char: 9
    4 = Hex: 41 Char: A
    5 = Hex: 32 Char: 2
    6 = Hex: 42 Char: B
    7 = Hex: 33 Char: 3
    Checksum:
    3030
    Synchronisation Error - ETX not received
    Expected ETX, received: A

    Finnaly, it shows something!
    thnx a lot, Sir.. really..really.. thnx! almost lost of hope here..
    anyway, is that any refrence so that i can store that tag code to database and modifiy that. so once again the tag pas through the reader, it shows that tag code with some text like name of parts, detil parts, function of parts, etc..??

    because i want to make some mini-smart-warehouse on my university.

    anyway about the documentation regarding the device like datasheet? or?

    @CDRIVE
    its ok, Sir..
    but how about my others question, about the refrence link or maybe ebooks, or something..??
    thnx beforehand, Sir.
    Last edited by cataztrophe; Jul 30th, 2013 at 01:33 AM. Reason: question

  15. #15
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    OOps - there's a Gremlin in the Code
    Code:
    If Asc(Mid$(strBuffer, 15, 1)) = 3 Then
    should be
    Code:
    If Asc(Mid$(strBuffer, 16, 1)) = 3 Then
    Sorry

  16. #16

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    OOps - there's a Gremlin in the Code
    Code:
    If Asc(Mid$(strBuffer, 15, 1)) = 3 Then
    should be
    Code:
    If Asc(Mid$(strBuffer, 16, 1)) = 3 Then
    Sorry
    thats why 'End Ok' doesnt appear when i try to run, well thnx again, Sir.
    anyway, like my post before, if i want to store it to database, is there any refrence link sir? or something?

  17. #17
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    Regarding my question about the documentation I wondered if there was any details regarding the Protocol, what the 'ignored bytes' might be and how the checksum is calculated. (I suspect you'll want to check the Checksum after you've read the Tag)

  18. #18
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Retrieve & Obtain RFID Tag with VB6

    Where the data is concatinated into text1 you could also concatinate it into a String Variable and then write that toa file or whatever
    Code:
                        For intI = 4 To 11
                            Text1.Text = Text1.Text & CStr(intI - 4) & " = "
                            Text1.Text = Text1.Text & " Hex: " & Hex(Asc(Mid$(strBuffer, intI, 1)))
                            Text1.Text = Text1.Text & Mid$(strBuffer, intI, 1) & vbNewLine
                            strTag = strTag & Mid$(strBuffer, intI, 1)
                        Next intI
                        '
                        ' here you'd write strTag to the file
                        '
                        Print #fileno, strTag
                        strTag = vbNullString

  19. #19

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    Where the data is concatinated into text1 you could also concatinate it into a String Variable and then write that toa file or whatever
    Code:
                        For intI = 4 To 11
                            Text1.Text = Text1.Text & CStr(intI - 4) & " = "
                            Text1.Text = Text1.Text & " Hex: " & Hex(Asc(Mid$(strBuffer, intI, 1)))
                            Text1.Text = Text1.Text & Mid$(strBuffer, intI, 1) & vbNewLine
                            strTag = strTag & Mid$(strBuffer, intI, 1)
                        Next intI
                        '
                        ' here you'd write strTag to the file
                        '
                        Print #fileno, strTag
                        strTag = vbNullString
    well, in datasheet of this product, i dont get any refrence/information regards of ur question sir, i think there was some byte ignored, thats why in the card it shows different number with code that appears on the program.

    well it doesnt matter i think, as long as i can store this code that got from the card itself, then operate it later. anyway, about this code, how can i grouping all the char number into one? and shows that is the code of tag/card. "how can i write the strTag to the file?"

    thnx again, Sir.

  20. #20
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    I think it's important to be able to interpret the tag properly. There seems to be some standards that the data will / should adhere to. Do you have any information regarding the tag itself. Also do you have the manufacturers name and model of the reader you are using?

  21. #21

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    I think it's important to be able to interpret the tag properly. There seems to be some standards that the data will / should adhere to. Do you have any information regarding the tag itself. Also do you have the manufacturers name and model of the reader you are using?
    well i got this reader and tag from some sidewalk store that sold this at medium price around $40 (on that level, ID-12 reader using IC 785). as long as this tag works well, doesnt matter for me.

    anyway, did you have any reference about using VB on inventory/warehouse management? so every time customer want to take the item on shelf, it will pass the reader and automatically will capture by database and process to the next one (reducing the stock, calculate the revenue, etc).

    thnx beforehand, Sir.

  22. #22
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    Well, I've found the data sheet for the device here: http://www.proto-pic.co.uk/content/d...-Datasheet.pdf.

    It looks as if you're using ASCII data format and that the data is actually 10 characters (bytes 2 to 11) rather than 8. You should change the for /next loop from
    Code:
    For intI = 4 To 11
    to
    Code:
    For intI = 2 To 11
    I'm not personaly aware of any references to VB6 Inventory Management Systems,there may be one or two ideas kicking around the Internet but it's not a particularly difficult task to start from scracth.

    To my mind, the most important thing you'll need to work out is the Database Design and what information you're going to keep regarding the products, given that you already have an idea of how an Inventory Management system might work.

  23. #23

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    35

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    Quote Originally Posted by Doogle View Post
    Well, I've found the data sheet for the device here: http://www.proto-pic.co.uk/content/d...-Datasheet.pdf.

    It looks as if you're using ASCII data format and that the data is actually 10 characters (bytes 2 to 11) rather than 8. You should change the for /next loop from
    Code:
    For intI = 4 To 11
    to
    Code:
    For intI = 2 To 11
    I'm not personaly aware of any references to VB6 Inventory Management Systems,there may be one or two ideas kicking around the Internet but it's not a particularly difficult task to start from scracth.

    To my mind, the most important thing you'll need to work out is the Database Design and what information you're going to keep regarding the products, given that you already have an idea of how an Inventory Management system might work.
    you sir really got my biggest respect!
    thnx (again) a lot, Sir.
    healthy & success always be with you & fam.

    Regards,
    cataztrophe.

  24. #24
    New Member
    Join Date
    May 2014
    Location
    Bandung,Indonesia
    Posts
    2

    Re: [RESOLVED] Retrieve & Obtain RFID Tag with VB6

    i have the same case with @cataztrophe,, i use the same starter kit,,
    and i have following all step in this post..
    but i have problem to get the tag ID..

    on this source code that include in starterkit, its show to convert hex to str to get the ID, but idk how to write it on vb cuz it was wrote on delphi

    take a look at

    Code:
    function tform1.hextoint(input : string):longint;
    var
        c,i : longint;
        input1 : string;
    begin
        c:=0;
        input1:='';
        for i:=length(input) downto 1 do input1:=input1+input[i]+'';
        input1:=uppercase(input1);
        for i:=1 to length(input1) do
        begin
          if (input1[i] in ['A'..'F'])and(i>1)then
              c:=((ord(input1[i])-ord('A')+10) shl (4*(i-1)))or c
          else
          if (input1[i] in ['0'..'9'])and(i>1)then
              c:=((ord(input1[i])-ord('0')) shl (4*(i-1))) or c
          else
          if (input1[i] in ['A'..'F'])and(i=1)then
              c:=(ord(input1[i])-ord('A')+10) or c
          else
          if (input1[i] in ['0'..'9'])and(i=1)then
              c:=(ord(input1[i])-ord('0')) or c;
        end;
        result:=c;
    end;
    and this is the delphi full source code
    Code:
    unit RFID;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, CPort, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Label1: TLabel;
        ComboBox1: TComboBox;
        Label2: TLabel;
        ComPort1: TComPort;
        Memo1: TMemo;
        Button1: TButton;
        ComDataPacket1: TComDataPacket;
        Timer1: TTimer;
        procedure FormShow(Sender: TObject);
        procedure ComPort1RxChar(Sender: TObject; Count: Integer);
        function hextoint(input : string):longint;
    //    procedure StopTesSer;
        procedure ComboBox1Change(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure Memo1Change(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
    //    procedure Button1Click(Sender: TObject);
    //    procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      data : byte;
      counter : byte;
      check_sum,nomor : string;
      flag_equ : boolean;
      sent, recv : byte;
    
    implementation
    
    {$R *.DFM}
    
    function tform1.hextoint(input : string):longint;
    var
        c,i : longint;
        input1 : string;
    begin
        c:=0;
        input1:='';
        for i:=length(input) downto 1 do input1:=input1+input[i]+'';
        input1:=uppercase(input1);
        for i:=1 to length(input1) do
        begin
          if (input1[i] in ['A'..'F'])and(i>1)then
              c:=((ord(input1[i])-ord('A')+10) shl (4*(i-1)))or c
          else
          if (input1[i] in ['0'..'9'])and(i>1)then
              c:=((ord(input1[i])-ord('0')) shl (4*(i-1))) or c
          else
          if (input1[i] in ['A'..'F'])and(i=1)then
              c:=(ord(input1[i])-ord('A')+10) or c
          else
          if (input1[i] in ['0'..'9'])and(i=1)then
              c:=(ord(input1[i])-ord('0')) or c;
        end;
        result:=c;
    end;
    
    procedure TForm1.FormShow(Sender: TObject);
    begin
      combobox1.ItemIndex:=0;
      comport1.Close;
      comport1.Port:=combobox1.Items.Strings[0];
      comport1.Open;
      nomor:='';
      check_sum:='';
      counter:=0;
      memo1.clear;
    {  timer1.Enabled:=false;
      timer1.interval:=25;
      button1.caption:='Tes Serial';}
    end;
    
    procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
    var i : integer;
    begin
    //  if button1.caption='Tes Serial' then
        for i:=0 to count do
        begin
          comport1.Read(data,1);
          inc(counter);
          case counter of
          1:
            if data = 2 then
            begin
              memo1.Clear;
              memo1.lines.add('Start OK');
            end
            else
            begin
              nomor:='';
              check_sum:='';
              counter:=0;
            end;
          12,13:
            begin
              check_sum:=check_sum+chr(data);
              memo1.lines.add('Checksum '+inttostr(counter-12)+' = '+inttohex(data,2));
            end;
          16:
            begin
              if data = 3 then
              begin
                label1.caption:='Nomor Kartu : '+inttostr(hextoint(nomor));
                memo1.lines.add('End Data');
              end
              else
                memo1.lines.add('End Data Invalid');
              nomor:='';
              check_sum:='';
              counter:=0;
            end;
          4..11:
            begin
              nomor:=nomor+chr(data);
              memo1.lines.add('Data ke '+inttostr(counter-4)+' = '+inttohex(data,2));
            end;
          end;
          sleep(50);
          application.ProcessMessages;
        end;
    end;
    
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
      comport1.Close;
      comport1.Port:=combobox1.Items.Strings[combobox1.ItemIndex];
      comport1.Open;
    end;
    
    {procedure TForm1.Button1Click(Sender: TObject);
    begin
      if button1.caption='Tes Serial' then
      begin
        button1.caption:='Stop Tes';
        combobox1.Enabled:=false;
        memo1.clear;
        flag_equ:=true;
        sent:=0;
        comport1.clearbuffer(true,false); // clear COM input buffer
        comport1.write(sent,1);
        timer1.Enabled:=true;
        end
      else
        StopTesSer;
    end;}
    
    {procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      comport1.read(recv,1);
      if recv<>sent then flag_equ:=false;
      memo1.lines.add(inttostr(sent)+' = '+inttostr(recv));
      if sent>=63 then
        StopTesSer
      else
      begin
        Inc(sent);
        Comport1.Write(sent,1);
      end;
    end;}
    
    {Procedure Tform1.StopTesSer;
    begin
      Button1.Caption:='Tes Serial';
      Timer1.Enabled:=False;
      Combobox1.Enabled:=True;
      if Flag_Equ then
        Memo1.Lines.Add('Tes serial : BAIK')
      else
        Memo1.Lines.Add('Tes serial : GAGAL');
      comport1.clearbuffer(true,false); // clear COM input buffer
    end;}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    
    end;
    
    procedure TForm1.Memo1Change(Sender: TObject);
    begin
    
    end;
    
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
    
    end;
    
    end.
    can anyone help me to convert this source to vb6?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width