MERVINOC
asked on
Question on MSCOMM
I am using mscomm to receive a string of data via rs232 port using mscomm.
I can view the string using multi-line text box. I need split the string into fixed length characters and insert them into a list box. I have tried EOF but does not work. I receive a rectangle shaped character at the beginning of each line, could I use this to create a loop.
I can view the string using multi-line text box. I need split the string into fixed length characters and insert them into a list box. I have tried EOF but does not work. I receive a rectangle shaped character at the beginning of each line, could I use this to create a loop.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi
Can u try this.
set up your port and ever thing
Private Sub Command1_Click()
If cmm = 0 Or setb = "" Then 'check and make sure settings are ok
MsgBox "Please Enter Comm settings to make your connection!", 46, "Comm"
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
Call settings_Click 'if not give'em a chance to fill it out
Exit Sub
End If
On Error GoTo err
MSComm1.CommPort = cmm 'set the settins and comm
MSComm1.settings = setb
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Do
Call waitscan 'open port and keep look for data arrival
Call showinput 'once data arrives go to it
Loop Until MSComm1.PortOpen = False
End If
err: 'error trap
MsgBox Error$, 48
MsgBox "Please check your comm settings", 48, "ERROR"
Unload Form1
Load Form1
Form1.Show
Exit Sub
End Sub
Public Sub waitscan()
Do While MSComm1.InBufferCount = 0 'wait for the buffer to start filling
DoEvents
Loop
End Sub
Dim strdata as string
Public Sub showinput()
MSComm1.InputLen = 1
strdata = MSComm1.Input
End sub
In the MSComm1.InputLen put your length to as a fixed character.
Then store it in strdata then insert the strdata in to the List box.
Try this out. if you have anything related to this ask me
Can u try this.
set up your port and ever thing
Private Sub Command1_Click()
If cmm = 0 Or setb = "" Then 'check and make sure settings are ok
MsgBox "Please Enter Comm settings to make your connection!", 46, "Comm"
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
Call settings_Click 'if not give'em a chance to fill it out
Exit Sub
End If
On Error GoTo err
MSComm1.CommPort = cmm 'set the settins and comm
MSComm1.settings = setb
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Do
Call waitscan 'open port and keep look for data arrival
Call showinput 'once data arrives go to it
Loop Until MSComm1.PortOpen = False
End If
err: 'error trap
MsgBox Error$, 48
MsgBox "Please check your comm settings", 48, "ERROR"
Unload Form1
Load Form1
Form1.Show
Exit Sub
End Sub
Public Sub waitscan()
Do While MSComm1.InBufferCount = 0 'wait for the buffer to start filling
DoEvents
Loop
End Sub
Dim strdata as string
Public Sub showinput()
MSComm1.InputLen = 1
strdata = MSComm1.Input
End sub
In the MSComm1.InputLen put your length to as a fixed character.
Then store it in strdata then insert the strdata in to the List box.
Try this out. if you have anything related to this ask me
can u place the code u r using ?
do u know the pattern of the string u r expecting from port ?
RThreshold Property
Sets and returns the number of characters to receive before the MSComm control sets the CommEvent property to comEvReceive and generates the OnComm event.
try to set RThreshold property to a no which u want to retireve the no of characters at a time
here is a sample code which demonstrates basic methods
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q262883&ID=KB;EN-US;Q262883
;-)
Shiju