Home > Software engineering >  Improve the VB program real time
Improve the VB program real time

Time:10-21

In using VB to develop a project recently, I met such a problem, I want to write a piece of code, the code according to the module can be cut into three parts, the three parts using string together two variables:

At the start of the implementation code module 1 spluttered pa, performed after variable 1 is true, he started a new round of cycle at the same time;
Code module 1 is true, have been waiting for 2 variables when variable 1 is true, applauded code module 2 began to clap, execution, will start to perform variable 1 become false, after execution of the variable to true;
Code module 3 variables have been waiting for 2 to true, when the variable is true, 2 code module 3 also applauded began to clap, execution, will start to perform variable 2 become false, after execution of the 2 is true, then wait for variable waiting for the next round of cycle;

The three parts of the code at the time of execution, the influence of each individual independence, only at the time of complete round of execution, to detect whether the related variables to ON, convenient to the next round of execution (such as code 2 after the execution of the round, detect variable 1 is true, if it is true, started a new round of executed)
The question now is, if I put three blocks of code string together, finished, if the code 1 has not yet been executed (I might have to perform to estimate code 1 1 s, because want to use more than N delay), then the code 2 will not be able to work, if you can make the code 1, 2, 3 and execution, so just after I finished my work in the code module, check whether you can start a new job, so that the machine efficiency is much higher!!
Question: how to do, can let three code modules work independently?



CodePudding user response:

Now that is a code change state, use event is one of the best,

It is not necessary to polling,

The saying why didn't you listen to me,

CodePudding user response:

Use the class module, define events, raiseevent when needed

CodePudding user response:

The building Lord give points and junction post rate is very low, refueling ah

CodePudding user response:

reference 1st floor caozhy response:
since is a code change state, use event is one of the best,

It is not necessary to polling,

The saying why didn't you listen to me,


Is to take the three code encapsulation class module in??

As a program that apes, I know I can't cry, but I'm really crying!!

CodePudding user response:

reference bcrun reply: 3/f
the building Lord give points and junction post rate is very low, refueling ah


Registration for a long time, but only recently come to post,,,

Poor, left this rations, moderator you don't suspicion points less,,,


Your family can not be good enough, give point what specific advice and, well,,,

I'm crying!!

CodePudding user response:

refer to the second floor zzyong00 response:
class module, define events, need raiseevent


Can you give some specific examples, examples of online mostly didn't comment, give a link line ah, also,

CodePudding user response:

Give yourself after PostMessage to trigger a task,

CodePudding user response:

Three parts to run independently, can only be multi-threading

CodePudding user response:

The building Lord give points and junction post rate is very low, refueling ah

CodePudding user response:

Rewsna3
reference 4 floor response:
Quote: refer to 1st floor caozhy response:

Now that is a code change state, use event is one of the best,

It is not necessary to polling,

The saying why didn't you listen to me,


Is to take the three code encapsulation class module in??

As a program that apes, I know I can't cry, but I'm really crying!!



How to write a class wept?

CodePudding user response:

The
refer to the original poster rewsna3 response:
... (I might have to perform to estimate code 1 1 s, because want to use more than N delay), then the code 2 will not be able to work, if you can make the code 1, 2, 3 and execution, so just after I finished my work in the code module, check whether you can start a new job, so that the machine efficiency is much higher!!
Question: how to do, can let three code modules work independently?


Is very simple, a lot of written in VB code thinking thinking "unification", always want to time and finish all the work with a boss program.

But in fact it is the practice of the wasted effort. Because the amount of code one, not only the internal relationship between the complex, high failure rate, maintenance is also difficult.

Moreover VB does not support multithreading.

So a simple solution: "independent" the task of multiple needs written individually, with a central dispatcher is responsible for the collection and the amount of all state deployment.
Like you this application can be split into four small, each one three tasks, control a again. Write separately, a separate debugging.
Than silly big cumbersome flexible don't know how many individual programs.
The only extra it just a little bit of mutual communication.
Want to simple point using DDE, after thinking about big become "enterprise", can use the database, the thinking of cow force point distribution can run again with TCP, road is lu tong Luo Ma anyway.

CodePudding user response:

With the event is better, throw out directly,
  • Related