| Author |
Message |
whassan
Joined: 25 Aug 2008 Posts: 1
|
25 Aug 2008 11:45 Serial Port In VB6 |
|
|
|
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.
|
|
| Back to top |
|
 |
Moof
Joined: 21 Nov 2003 Posts: 154 Helped: 6 Location: Argentina
|
25 Aug 2008 13:38 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
|
|
| Back to top |
|
 |
Darth Maul
Joined: 19 Jul 2007 Posts: 18 Helped: 2 Location: Yogyakarta, Indonesia
|
29 Aug 2008 7:57 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.
|
|
| Back to top |
|
 |