Discussion in "Software" started by    Harrison    Aug 21, 2010.
Sat Aug 21 2010, 08:55 am
#1
Hi all,

I have a very simple project. Just interface 8051 with VB by serial port. I tested my c program and circuit with Hyper Terminal. I had no problem (both TX and RX). But now I use my VB program, I only can do TX but no RX. Can you guys help me?

See VB program in attachment
Attachment
Mon Aug 23 2010, 03:50 pm
#2
you are not handling OnComm events... incase new data comes, it will be generate an event.

here is a small sample code for mscomm event

      Private Sub MSComm1_OnComm()
         Dim InBuff As String

         Select Case MSComm1.CommEvent
         ' Handle each event or error by placing
         ' code below each case statement.

         ' This template is found in the Example
         ' section of the OnComm event Help topic
         ' in VB Help.

         ' Errors
            Case comEventBreak   ' A Break was received.
            Case comEventCDTO    ' CD (RLSD) Timeout.
            Case comEventCTSTO   ' CTS Timeout.
            Case comEventDSRTO   ' DSR Timeout.
            Case comEventFrame   ' Framing Error.
            Case comEventOverrun ' Data Lost.
            Case comEventRxOver  ' Receive buffer overflow.
            Case comEventRxParity   ' Parity Error.
            Case comEventTxFull  ' Transmit buffer full.
            Case comEventDCB     ' Unexpected error retrieving DCB]

         ' Events
            Case comEvCD   ' Change in the CD line.
            Case comEvCTS  ' Change in the CTS line.
            Case comEvDSR  ' Change in the DSR line.
            Case comEvRing ' Change in the Ring Indicator.
            Case comEvReceive ' Received RThreshold # of chars.
               InBuff = MSComm1.Input
               Call HandleInput(InBuff)
            Case comEvSend ' There are SThreshold number of
                           ' characters in the transmit buffer.
            Case comEvEOF  ' An EOF character was found in the
                           ' input stream.
         End Select

      End Sub
Mon Aug 23 2010, 03:51 pm
#3
[Topic moved to Computer Related > Software]
Mon Aug 30 2010, 07:26 pm
#4
Hi Ajay,

you mean I can add the code under Private Sub MSComm1_OnComm()? I tried, but doesn't work.
like the attachment?? please feel free to edit the code to make it work, thank you.
Attachment


[ Edited Mon Aug 30 2010, 07:27 pm ]
Tue Aug 31 2010, 03:28 am
#5
Harrison, it may be little homework for you, but please try to get a sample software for serial communication in VB6 from google and see how things are done.

or you can make use of one my software like "PC Remote" or "HA Server" in VB projects from download section and see what i did there.

its 3:30am i dont have enough time to write codes.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Davidbab
Tue Apr 23 2024, 10:41 am
Richardrit
Tue Apr 23 2024, 09:54 am
HenryLaf
Mon Apr 22 2024, 03:50 pm
bleradrar
Mon Apr 22 2024, 06:38 am
ppu-pro_ka
Sun Apr 21 2024, 07:39 pm
Infewow
Sun Apr 21 2024, 06:30 pm
HumanTak
Sun Apr 21 2024, 12:26 pm
Zacharybus
Sun Apr 21 2024, 02:45 am