Problem with entering data through the serial port in VB6

Status
Not open for further replies.

whassan

Newbie level 1
Joined
Aug 25, 2008
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
I have a (weight Bridge measure machine) for Weight the big Car . it have a serial port .

.We enter data through serial port in vb code but it gives in text box unclear letters and numbers.
#%y;< YW
this is code I used:

Private Sub Form_Load()
With MSComm1
.CommPort = 1
.Handshaking = comRTSXOnXOff
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
.EOFEnable = True
.InputMode = comInputModeText
.InputLen = 0
End With
end sub
Private Sub MSComm1_OnComm()

Dim Buffer As String
If MSComm1.CommEvent = 2 Then
Buffer = Buffer & MSComm1.Input & Chr(11)


Buffer = StrConv(MSComm1.Input, vbUnicode)


Me.Text1 = Buffer

end if


end sub
I tried all the solution but it did not give a result.


Please if someone have a solution help me to solve it.
 

Re: Serial Port In VB6

It could be because the data you are receiving is not ascii.

If that is the problem you can use Asc() to convert your data.


Here is an example

http://msdn.microsoft.com/en-us/library/zew1e4wc(VS.71).aspx
 

Serial Port In VB6

that Buffer variable should be declared as variant. whenever you send or receive data thorugh MSComm component, pass the data from/to a variant variable. the variant variable was assigned from/to other variable, be it a string (if you send or receive text data) or a byte array (if you send or receive raw binary data). cmiiw.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…