Rs-232 Vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OldSchool
    New Member
    • Nov 2006
    • 27

    Rs-232 Vb6

    Sir,

    I have my project its a Barcode System, since i dont know yet how to use RS-232, My question is:

    1. RS-232 is only for Sending Date and Reading Data? its just for open the MScomm port and Settings.? How can i interface it in VB6 Programming?

    Sir,
    can you give explanation of these code:

    MSComm1.PortOpe n=True
    Ms.comm1.Settin gs=9600,n,1,8

    Sir is there other code need to enabled Rs-232?

    2. Sir can you provide me samples of Barcode system using RS-232 in VB6?


    Sir, thank you in advance! and More power

    Julius
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by OldSchool
    Sir,

    I have my project its a Barcode System, since i dont know yet how to use RS-232, My question is:

    1. RS-232 is only for Sending Date and Reading Data? its just for open the MScomm port and Settings.? How can i interface it in VB6 Programming?

    Sir,
    can you give explanation of these code:

    MSComm1.PortOpe n=True
    Ms.comm1.Settin gs=9600,n,1,8

    Sir is there other code need to enabled Rs-232?

    2. Sir can you provide me samples of Barcode system using RS-232 in VB6?


    Sir, thank you in advance! and More power

    Julius
    Hey Julius, Welcome to the scripts. You are posting your posts in the wrong forums.
    That first one for example should have been here:


    And this qusetion is better asked in the vb forum

    Comment

    • OldSchool
      New Member
      • Nov 2006
      • 27

      #3
      Originally posted by r035198x
      Hey Julius, Welcome to the scripts. You are posting your posts in the wrong forums.
      That first one for example should have been here:


      And this qusetion is better asked in the vb forum
      Thank you sir for informing me.
      Julius

      Comment

      • OldSchool
        New Member
        • Nov 2006
        • 27

        #4
        Rs-232 VB6

        Sir,

        I have my project its a Barcode System, since i dont know yet how to use RS-232, My question is:

        1. RS-232 is only for Sending Date and Reading Data? its just for open the MScomm port and Settings.? How can i interface it in VB6 Programming?

        Sir,
        can you give explanation of these code:

        MSComm1.PortOpe n=True
        Ms.comm1.Settin gs=9600,n,1,8

        Sir is there other code need to enabled Rs-232?

        2. Sir can you provide me samples of Barcode system using RS-232 in VB6?


        Sir, thank you in advance! and More power

        Julius

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by OldSchool
          Thank you sir for informing me.
          Julius
          Welcome. No need for the "sir" next time though.

          Comment

          • Hansi65
            New Member
            • Oct 2006
            • 13

            #6
            This worked for me with an serial Metrologic Voyager:

            Suppose your MSComm control is named BarcodeComm
            Settings are: 9600,n,8,1

            Code:
            'in your forms declaration section
            Dim WithEvents BarcodeTimer As Timer
            
            Initialization somwhere, e.g. in form_Load: 
               BarcodeComm.CommPort = 1
               BarcodeComm.PortOpen = True
               BarcodeTimer.Interval = 100
               BarcodeTimer.Enabled = True
            
            'use a timer to read from the serial port:
            Private Sub BarcodeTimer_Timer()
               Dim barcodeRead as String 
               barcodeRead = ReadBarcode()
            
               if barcodeRead <> "" then
                  'handling the code read...
                   Msgbox "Barcode=" + barcodeRead
               Endif 	
            End Sub
            
            Function ReadBarcode() As String
               On Error GoTo ReadBarcode_ERROR
               
               Static comInput As String
               Static ReadBarcodeRunning As Integer
             
               If ReadBarcodeRunning Then
                  ReadBarcode = ""
                  Exit Function
               Else
                  ReadBarcodeRunning = True
            
                  If BarcodeComm.InBufferCount > 0 Or Len(comInput) > 0 Then
                     Do
                        comInput = comInput + comControl.Input
                        
                        'if received data contains CR+LF, then exit		
                        If InStr(comInput, Chr$(13) + Chr$(10) > 0 Then
                           Exit Do
                        Else
                           dummy = DoEvents()
                        End If
                     Loop
                     
                     'remove CR+LF 
                     posP = InStr(comInput, Chr$(13) + Chr$(10))
                     t$ = Left$(comInput, posP - 1)
            
            	 'anything beyond CRLF belongs to next barcode	
                     comInput = MID$(comInput, posP + 2)
                     
                     ReadBarcode = t$
                  Else
                     ReadBarcode = ""
                  End If
                  
                  ReadBarcodeRunning = False
               End If
               
            ReadBarcode_EXIT:
               Exit Function
               
            ReadBarcode_ERROR:
               MsgBox "Error in ReadBarcode:" + vbcrlf + Error$
               Resume Next
            End Function
            BEWARE:
            make sure that the barcode scanner adds CR+LF as delimiters after each barcode or adjust the delimiter detection in ReadBarcode() accordingly

            Let me know if this helped a little...

            Comment

            • OldSchool
              New Member
              • Nov 2006
              • 27

              #7
              Thank You Sir, for the Code you gave me... Thanks Again God Bless U...

              Julius


              Originally posted by Hansi65
              This worked for me with an serial Metrologic Voyager:

              Suppose your MSComm control is named BarcodeComm
              Settings are: 9600,n,8,1

              Code:
              'in your forms declaration section
              Dim WithEvents BarcodeTimer As Timer
              
              Initialization somwhere, e.g. in form_Load: 
                 BarcodeComm.CommPort = 1
                 BarcodeComm.PortOpen = True
                 BarcodeTimer.Interval = 100
                 BarcodeTimer.Enabled = True
              
              'use a timer to read from the serial port:
              Private Sub BarcodeTimer_Timer()
                 Dim barcodeRead as String 
                 barcodeRead = ReadBarcode()
              
                 if barcodeRead <> "" then
                    'handling the code read...
                     Msgbox "Barcode=" + barcodeRead
                 Endif 	
              End Sub
              
              Function ReadBarcode() As String
                 On Error GoTo ReadBarcode_ERROR
                 
                 Static comInput As String
                 Static ReadBarcodeRunning As Integer
               
                 If ReadBarcodeRunning Then
                    ReadBarcode = ""
                    Exit Function
                 Else
                    ReadBarcodeRunning = True
              
                    If BarcodeComm.InBufferCount > 0 Or Len(comInput) > 0 Then
                       Do
                          comInput = comInput + comControl.Input
                          
                          'if received data contains CR+LF, then exit		
                          If InStr(comInput, Chr$(13) + Chr$(10) > 0 Then
                             Exit Do
                          Else
                             dummy = DoEvents()
                          End If
                       Loop
                       
                       'remove CR+LF 
                       posP = InStr(comInput, Chr$(13) + Chr$(10))
                       t$ = Left$(comInput, posP - 1)
              
              	 'anything beyond CRLF belongs to next barcode	
                       comInput = MID$(comInput, posP + 2)
                       
                       ReadBarcode = t$
                    Else
                       ReadBarcode = ""
                    End If
                    
                    ReadBarcodeRunning = False
                 End If
                 
              ReadBarcode_EXIT:
                 Exit Function
                 
              ReadBarcode_ERROR:
                 MsgBox "Error in ReadBarcode:" + vbcrlf + Error$
                 Resume Next
              End Function
              BEWARE:
              make sure that the barcode scanner adds CR+LF as delimiters after each barcode or adjust the delimiter detection in ReadBarcode() accordingly

              Let me know if this helped a little...

              Comment

              Working...