|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Code Runs During CompileI have a app that contains a usercontrol in the project.
The usercontrol is on one form. When I compile it runs the usercontrol code during the writing phase of the compile. What causes this and is there a way to avoid it? The compile errors out because in the usercontrol it calls a sub that has a filename that is not defined yet and is trying to open the un-named file(gets defined in the main app when it runs). I have a Debug.Assert False in the error handler and the compile writing stops dead there. I OK then I F8 it until it completes but I am not totally sure if the compile is good. No other errors occurr. What's up with that? VB6 SP6 "Bee" <B**@discussions.microsoft.com> wrote Try checking the AmbientProperties object (UserMode) and see if> I have a app that contains a usercontrol in the project. > The usercontrol is on one form. > When I compile it runs the usercontrol code during the writing phase of the > compile. > What causes this and is there a way to avoid it? that will help.... LFS
Show quote
Hide quote
"Bee" <B**@discussions.microsoft.com> wrote in message I just ran a simple test (added a Debug.Print "<eventname>" to a few events news:4A48CDEF-DC68-42F1-9337-44DA585FB3CE@microsoft.com... >I have a app that contains a usercontrol in the project. > The usercontrol is on one form. > When I compile it runs the usercontrol code during the writing phase of > the > compile. > What causes this and is there a way to avoid it? > > The compile errors out because in the usercontrol it calls a sub that has > a > filename that is not defined yet and is trying to open the un-named > file(gets defined in the main app when it runs). > I have a Debug.Assert False in the error handler and the compile writing > stops dead there. > I OK then I F8 it until it completes but I am not totally sure if the > compile is good. > No other errors occurr. > > What's up with that? and checked the immediate window to see what got printed) and confirmed the Initialize event is fired during compilation. This was a Standard EXE project with a UserControl added to it. I don't know if this event would fire if the UserControl were instead part of an ActiveX Control project when you compile (easy enough to test this too I guess....nope, not in my test at least). I can't say I know why this event fires when you compile, but for whatever reason VB instantiates the usercontrol during compilation (also don't know if this would be considered a bug or if it's maybe documented somewhere). It looks like you'll just need to write code to deal with it. Perhaps you can check to see if Len(filename) = 0 and not run your code to open the file if it is (or better, only attempt to open it if Len(filename) >0). Or perhaps you'll need to do something a bit more drastic. If worse comes to worst and you can't work around this any other way, I suppose you could make your UserControl an OCX instead of that module just being added to another type of project. -- Mike "Bee" <B**@discussions.microsoft.com> wrote in message
http://vbnet.mvps.org/code/core/isinide.htm
news:4A48CDEF-DC68-42F1-9337-44DA585FB3CE@microsoft.com... > is there a way to avoid it? "Nobody" <nob***@nobody.com> wrote in message I don't think you understood the problem. <g>news:uwsv9onrJHA.2484@TK2MSFTNGP03.phx.gbl... > "Bee" <B**@discussions.microsoft.com> wrote in message > news:4A48CDEF-DC68-42F1-9337-44DA585FB3CE@microsoft.com... >> is there a way to avoid it? > > http://vbnet.mvps.org/code/core/isinide.htm > -- Mike
Show quote
Hide quote
"Bee" <B**@discussions.microsoft.com> escribió en el mensaje Yes, some events are fired when you compile. But I think there must be news:4A48CDEF-DC68-42F1-9337-44DA585FB3CE@microsoft.com... >I have a app that contains a usercontrol in the project. > The usercontrol is on one form. > When I compile it runs the usercontrol code during the writing phase of > the > compile. > What causes this and is there a way to avoid it? > > The compile errors out because in the usercontrol it calls a sub that has > a > filename that is not defined yet and is trying to open the un-named > file(gets defined in the main app when it runs). > I have a Debug.Assert False in the error handler and the compile writing > stops dead there. > I OK then I F8 it until it completes but I am not totally sure if the > compile is good. > No other errors occurr. > > What's up with that? > VB6 SP6 something wrong with the design. What UserControl event is triggering that file read? I think you should explain how your code works in order to help you find out what's wrong and what to change. I can guess that you shouldn't be reading that file at that time.
Replace one occurence of string within string at certain position
Using GetSaveFileName API with VB6 Beep Again URLDownloadToFile API failing due to disclaimer page IsVista SQL Server Compact Edition with VB6 VB6 IDE Find doesn't Subscript out of range VB 6 on loading a form ordered list - sorta ABAP? |
|||||||||||||||||||||||