سؤال

I have a requirement in visual basic6 where I want to send commands to a machine connected to my PC. I can send the command only after getting the acknowledgement from it.It is like this. Sleep after I send the first command will make the program inactive and I cannot receive the acknowledgment.

So I am thinking of using variables or flags and increment in the subsequent modules for the delay. But I am not sure how to implement the thing. I have included the sample rather incomplete code for this. But I dont know how it can give the delay. I am thinking of timers,goto. Is there anyother way to implement the delay here.

Module where I send the command

//Sending Module

Sendcommand()

Send command CMD1.
If (flagcheck =2)
Send command CMD2.

Module where I receive the acknowledgment command

Receive command()

Select cmdname
public flagcheck=0
CASE ACK1.1
        flagcheck=flagcheck+1
CASE ACK1.2
        flagcheck=flagcheck+1
هل كانت مفيدة؟

المحلول

You can generally do something like

SendCommandOne

While flag = 0 ' ReceiveCommand would set flag to 1
    DoEvents
End While

SendCommandTwo

etc

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top