By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Rs-232 Vb6

P: 27
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.PortOpen=True
Ms.comm1.Settings=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
Nov 13 '06 #1
Share this Question
Share on Google+
6 Replies


10K+
P: 13,264
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.PortOpen=True
Ms.comm1.Settings=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:
http://www.thescripts.com/forum/forum30.html

And this qusetion is better asked in the vb forum
Nov 13 '06 #2

P: 27
Hey Julius, Welcome to the scripts. You are posting your posts in the wrong forums.
That first one for example should have been here:
http://www.thescripts.com/forum/forum30.html

And this qusetion is better asked in the vb forum
Thank you sir for informing me.
Julius
Nov 13 '06 #3

P: 27
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.PortOpen=True
Ms.comm1.Settings=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
Nov 13 '06 #4

10K+
P: 13,264
Thank you sir for informing me.
Julius
Welcome. No need for the "sir" next time though.
Nov 13 '06 #5

P: 13
This worked for me with an serial Metrologic Voyager:

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

Expand|Select|Wrap|Line Numbers
  1. 'in your forms declaration section
  2. Dim WithEvents BarcodeTimer As Timer
  3.  
  4. Initialization somwhere, e.g. in form_Load: 
  5.    BarcodeComm.CommPort = 1
  6.    BarcodeComm.PortOpen = True
  7.    BarcodeTimer.Interval = 100
  8.    BarcodeTimer.Enabled = True
  9.  
  10. 'use a timer to read from the serial port:
  11. Private Sub BarcodeTimer_Timer()
  12.    Dim barcodeRead as String 
  13.    barcodeRead = ReadBarcode()
  14.  
  15.    if barcodeRead <> "" then
  16.       'handling the code read...
  17.        Msgbox "Barcode=" + barcodeRead
  18.    Endif     
  19. End Sub
  20.  
  21. Function ReadBarcode() As String
  22.    On Error GoTo ReadBarcode_ERROR
  23.  
  24.    Static comInput As String
  25.    Static ReadBarcodeRunning As Integer
  26.  
  27.    If ReadBarcodeRunning Then
  28.       ReadBarcode = ""
  29.       Exit Function
  30.    Else
  31.       ReadBarcodeRunning = True
  32.  
  33.       If BarcodeComm.InBufferCount > 0 Or Len(comInput) > 0 Then
  34.          Do
  35.             comInput = comInput + comControl.Input
  36.  
  37.             'if received data contains CR+LF, then exit        
  38.             If InStr(comInput, Chr$(13) + Chr$(10) > 0 Then
  39.                Exit Do
  40.             Else
  41.                dummy = DoEvents()
  42.             End If
  43.          Loop
  44.  
  45.          'remove CR+LF 
  46.          posP = InStr(comInput, Chr$(13) + Chr$(10))
  47.          t$ = Left$(comInput, posP - 1)
  48.  
  49.      'anything beyond CRLF belongs to next barcode    
  50.          comInput = MID$(comInput, posP + 2)
  51.  
  52.          ReadBarcode = t$
  53.       Else
  54.          ReadBarcode = ""
  55.       End If
  56.  
  57.       ReadBarcodeRunning = False
  58.    End If
  59.  
  60. ReadBarcode_EXIT:
  61.    Exit Function
  62.  
  63. ReadBarcode_ERROR:
  64.    MsgBox "Error in ReadBarcode:" + vbcrlf + Error$
  65.    Resume Next
  66. 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...
Nov 15 '06 #6

P: 27
Thank You Sir, for the Code you gave me... Thanks Again God Bless U...

Julius


This worked for me with an serial Metrologic Voyager:

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

Expand|Select|Wrap|Line Numbers
  1. 'in your forms declaration section
  2. Dim WithEvents BarcodeTimer As Timer
  3.  
  4. Initialization somwhere, e.g. in form_Load: 
  5.    BarcodeComm.CommPort = 1
  6.    BarcodeComm.PortOpen = True
  7.    BarcodeTimer.Interval = 100
  8.    BarcodeTimer.Enabled = True
  9.  
  10. 'use a timer to read from the serial port:
  11. Private Sub BarcodeTimer_Timer()
  12.    Dim barcodeRead as String 
  13.    barcodeRead = ReadBarcode()
  14.  
  15.    if barcodeRead <> "" then
  16.       'handling the code read...
  17.        Msgbox "Barcode=" + barcodeRead
  18.    Endif     
  19. End Sub
  20.  
  21. Function ReadBarcode() As String
  22.    On Error GoTo ReadBarcode_ERROR
  23.  
  24.    Static comInput As String
  25.    Static ReadBarcodeRunning As Integer
  26.  
  27.    If ReadBarcodeRunning Then
  28.       ReadBarcode = ""
  29.       Exit Function
  30.    Else
  31.       ReadBarcodeRunning = True
  32.  
  33.       If BarcodeComm.InBufferCount > 0 Or Len(comInput) > 0 Then
  34.          Do
  35.             comInput = comInput + comControl.Input
  36.  
  37.             'if received data contains CR+LF, then exit        
  38.             If InStr(comInput, Chr$(13) + Chr$(10) > 0 Then
  39.                Exit Do
  40.             Else
  41.                dummy = DoEvents()
  42.             End If
  43.          Loop
  44.  
  45.          'remove CR+LF 
  46.          posP = InStr(comInput, Chr$(13) + Chr$(10))
  47.          t$ = Left$(comInput, posP - 1)
  48.  
  49.      'anything beyond CRLF belongs to next barcode    
  50.          comInput = MID$(comInput, posP + 2)
  51.  
  52.          ReadBarcode = t$
  53.       Else
  54.          ReadBarcode = ""
  55.       End If
  56.  
  57.       ReadBarcodeRunning = False
  58.    End If
  59.  
  60. ReadBarcode_EXIT:
  61.    Exit Function
  62.  
  63. ReadBarcode_ERROR:
  64.    MsgBox "Error in ReadBarcode:" + vbcrlf + Error$
  65.    Resume Next
  66. 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...
Nov 16 '06 #7

Post your reply

Sign in to post your reply or Sign up for a free account.