Home > Software engineering >  VB code, please the great god
VB code, please the great god

Time:10-05

I want to realize a function

1. Determine file
1.1 if there is, just delete the file
1.2 if not, just go down the program

2. If not, will perform a code, let him produce,
Execution may fail
2.1. Cycle three times, each time to determine whether to generate this file, if produce, is out of circulation, continue to go down (generally within 3 times will certainly generated)

Code is as follows: but there have been problems, give advice or comments please
Public Sub Main ()
'delete old file'
If dir (" E: \ TEST \ iqdc.zip ") & lt;> "" Then
Kill (" E: \ iqdc TXT ")
End the If

'judge File exist and cycle 3 times if Fail'
Dim Flag=0
The Do While Flag & lt; 3
'to execute the generated files'
If dir (" E: \ TEST \ iqdc. TXT ") & lt;> "" Then Exit the Do
Flag=Flag + 1
Loop

End Sub

CodePudding user response:

Debugging first and specific problems on the first, not solve the question again

CodePudding user response:

Three loops to much time, are you sure you can generate the file?

In addition, you said the problem is?

CodePudding user response:

Within 3 times will be able to generate the tried

Another question: what kind of software, VS use debug the test, that doesn't seem to be


See, the first code looks no problem

CodePudding user response:

What do you want to do debug? If you can generate the file 3 times, so now is not running is normal,

In addition, the generated file is called an external process? Don't see a file code,
There is another, why is the top of the judgment of the zip file exists, and TXT file is deleted?? If write wrong

To generate a word also can be in in suspicious code below plus msgbox variable to see whether the expected situation,

CodePudding user response:

Delete the ZIP, originally written wrong

To say the shining debugging command, like in c #, do a breakpoint debugging
C # I do breakpoint debugging can directly, and this seems to be no, have the features similar to c #
  •  Tags:  
  • VBA
  • Related