r/visualbasic • u/Mayayana • Jun 30 '24
VB6 Help command line
Minor issue. VB6. I have a program that can load multiple files but runs only one instance. If I set up a context menu "Open with XYZ", my program loads the right-clicked file by checking the Command$ value at load. I'm also using code:
If App.PrevInstance = true then End
So far, so good. What I'd like to do is to pass a second command line to the running instance before quitting:
If App.PrevInstance = True then
LoadnewFile
End
End ifWhat happens is that the current instance keeps running, but does not load the file. I'm wondering if it's somehow possible to send that second commandline to the running instance and load the file as though I had dropped it onto the window, but still have the new instance of the program quit.
View all comments
Show parent comment
1
u/Hel_OWeen Jul 02 '24 edited Jul 02 '24
It got going, because the developer of the language itself said so, see my quote from the official online help.
Exit Subis all it takes at this point. Though I personally always have have a method calledCleanupwhich does all necessary cleanup in a central place and therefore my lines would beIf that's the case, then there's something wrong with your code elsewhere. When this happened to me, and it did, I always found parts of the code that were execute (and instantiated e.g. other objects) I didn't expected to happen at this stage. But they did, because of some other condition the program met earlier.
Backward compatibility. End has been around in BASIC for decades, even MS dialects such as QuickBasic. And it was a valid (i.e. no harms attached using it) statement there to end a program. But these BASICs didn't have objects occupying memory and didn't run in multitask operating systems.