For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > MScomm control send problem.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MScomm control send problem.
Boki

2005-12-13, 3:55 am

Hi All,
These code can't work. Could you please advice ?
Why can't I send a single byte by:

''''''''''''''''''''''''''''''''''''''''
'
dim a as byte
a=10
mscomm1.output = a
''''''''''''''''''''''''''''''''''''''''
'
Thank you very much!

Best regards,
Boki.


Code:
===============================
Private Sub Boki_Walk(A As Byte, B As Byte, C As Integer)

MSComm1.Output = B
MSComm1.Output = CByte(data \ 256)
MSComm1.Output = CByte(data) '//send low byte

End Sub
===============================


David Youngblood

2005-12-13, 7:55 am

"Boki" <bokiteam@ms21.hinet.net> wrote...
> These code can't work. Could you please advice ?
> Why can't I send a single byte by:
>
> ''''''''''''''''''''''''''''''''''''''''
'
> dim a as byte
> a=10
> mscomm1.output = a
> ''''''''''''''''''''''''''''''''''''''''
'


MSComm.Output requires a string or a byte array. No other data type can be sent
without conversion to a string or byte array. Input has the same restrictions.

David


>
> Best regards,
> Boki.
>
>
> Code:
> ===============================
> Private Sub Boki_Walk(A As Byte, B As Byte, C As Integer)
>
> MSComm1.Output = B
> MSComm1.Output = CByte(data \ 256)
> MSComm1.Output = CByte(data) '//send low byte
>
> End Sub
> ===============================
>
>



Boki

2005-12-13, 6:56 pm

could you please advice when we want to send a single hex data?

ex: pass a byte variable through function call...

Best regards,
Boki.


"David Youngblood" <dwy@flash.net> 撰寫於郵件新聞:eWHEzd9$FHA.2320@TK2MSFTNGP11.phx.gbl...
> "Boki" <bokiteam@ms21.hinet.net> wrote...
>
> MSComm.Output requires a string or a byte array. No other data type can be
> sent
> without conversion to a string or byte array. Input has the same
> restrictions.
>
> David
>
>
>
>



Dick Grier

2005-12-14, 3:55 am

Dim Buffer(0) As Byte
Buffer(0) = 10
MSComm1.Output = Buffer

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.


Boki

2005-12-14, 3:55 am

Thanks a lot.

Best regards,
Boki.

"Dick Grier" <dick_grierNOSPAM@msn.com> 撰寫於郵件新聞:%23Si$GWGAGHA.2912@tk2msftngp13.phx.gbl...
> Dim Buffer(0) As Byte
> Buffer(0) = 10
> MSComm1.Output = Buffer
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com