In the input data of the txtbox a, b, click on the calculation, calculation program will refer to external exe, generate 2. TXT output file
Please input what code to run in VB after the exe file, and then call 2. TXT data
CodePudding user response:
I'm sorry, but this I learn is c #, not the VB, can't help you, I'm sorry,CodePudding user response:
I'm sorry that your exe program is what to do, don't know, what role to run it, don't know, where is your variable TXT assigned values, does not see, so write 2. TXT should do not have any content,VB call external exe files, must know the add. Exe file handle, can call this exe content, the more troublesome, you should have a good understanding of VB call external exe file operations,
CodePudding user response:
The thing he is good, also call external calculator?CodePudding user response:
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const PROCESS_QUERY_INFORMATION=& amp; H400
Private Const STATUS_PENDING=& amp; H103
Private Sub RunShell (cmdline As String)
Dim hProcess As Long
Dim ProcessId As Long
Dim ExitCode As Long
ProcessId=Shell (cmdline, 1)
HProcess=OpenProcess (PROCESS_QUERY_INFORMATION, False, ProcessId)
Do
Call GetExitCodeProcess (hProcess, ExitCode)
DoEvents
Loop While ExitCode=STATUS_PENDING
Call the CloseHandle (hProcess)
End Sub
With the above function call, will wait for another go down again after the end of the program,
Step1 RunShell you to invoke applications
Step2 read 2. TXT
CodePudding user response:
Just didn't see the building code, the original poster should be in touch, he in the add. Exe is ready in read a file, and add and written to the 2. TXT, the original poster can, according to my method operatingThe shell to RunShell
Other what all need not change,
CodePudding user response:
1, enabling external application, written by external program ini file value is empty,2, the external program calculation, write ini file is not null,
3, the main program read ini file, to determine whether to run ended, not run out, time delay waiting, set a maximum value, the maximum time, the judgment error, recalculate,
CodePudding user response:
This kind of question: I was in 4th floor method to deal with it,But Do I in the loop are added Sleep, it won't cause high CPU usage,
As long as the real-time performance is not too demanding (allow about 15 ms delay), suggest or with Sleep,
This way is very flexible, you can set the longest waiting time, can be "abort waiting", etc.,
I think compared to the 6th floor said no advantage;
Especially the original poster said "external program" is a third party, it doesn't give you what to write ini files, you will be completely helpless,
CodePudding user response:
Need to have a mechanism to judge when external program to complete its work.If not, then use a timer periodic inspection of the program will generate a results file, so will delay for a period of time to read.