Is there a way of telling if a usercontrols parent is running in debug mode (in the VB IDE) or in compile mode (compiled and out in the real world)
and help would be greatly appreciated.
Printable View
Is there a way of telling if a usercontrols parent is running in debug mode (in the VB IDE) or in compile mode (compiled and out in the real world)
and help would be greatly appreciated.
Ok from expierance....if a project has a breakpoint this is what will happen. In the IDE will bounce into the code line ready for happy debugging...l love the vb debugger....if the project is compliled then it will not drop into debug mode. VB does not compile break points into object code.
Probably doesn't answer your question...maybe a few more lines explaining the problem.
Regards
Jethro
I think he means something like this.
you are running the program from the VBIDE, a messagebox comes up saying
"You are running in the VB IDE"
if it is running compiled then
"you are running a compiled program"
something like that sam?
I know it doesnt answer your Q?? but is that what you wanted?
This should help you
Run in the IDE and then run compiled...see the difference!
'code
Private Sub Form_Load()
On Error GoTo Result
Debug.Print (1 / 0) 'this won't work if compiled
MsgBox "This is compiled mode"
Exit Sub
Result:
MsgBox "This is debug mode"
End Sub
Kumaraguru San,
I am sorry to tell you that your method cannot work. I TRIED, under both situation, it return to be Debug Mode
To detect whether one is in IDE mode, is something I searched for quite a long time.
Currently, I use a very stupid way, I put a constant in the command$ under the project setup. So that i detect whethter command$ is empty to tell whether it is in debug mode.
Sound Stupid?
So far it works for me. If anybody have good idea, please tell us!
OK Declare this:
then use...Code:Private Declare Function GetModuleFileName Lib "kernel32" _
Alias "GetModuleFileNameA" (ByVal hModule As Long, _
ByVal lpFileName As String, ByVal nSize As Long) As Long
A little clumsy, but it works :pCode:'Guess whether or not the application is being run in debug
'mode from inside VB or as a real application
Public Function IsDebugging() As Boolean
Dim strMod As String * 2048
Dim lLen As Long
lLen = GetModuleFileName(App.hInstance, strMod, 2048)
IsDebugging = UCase(Mid(strMod, lLen - 6, 7)) = "VB6.EXE"
End Function
:cool:
Dan
Judds seem to be the right way of doing it, kmchong's way won't work, I want a usercontrol which will raise warnings in debug mode if it's used wrong, (rather than raise errors) and I don't want to disturb the end user in his compiled app. So I can't tell him to use a constant command line.
shouldn't UserControl.Ambient.UserMode do the trick ?
No, that says if the parent is at design time or run time.
Sorry folks,
I did not notice that you are talking about ' User control '.
Well the solution is again simple...This time I modified the code
to detect IDE design mode, Ide Run Mode and Compiled run.
In the user Control code paste this. Later add this user control to
a form to see results.
Private Sub UserControl_Show()
On Error GoTo IDE_Mode
Debug.Print (1 / 0) 'while in IDE this will raise an error.
MsgBox "Compiled run"
Exit Sub
IDE_Mode:
If UserControl.Ambient.UserMode = True Then
MsgBox "IDE Run"
Else
MsgBox "IDE Design"
End If
End Sub
Hey, I need feedback guys,
Did this code work or not ?
[Edited by G.Kumaraguru on 05-30-2000 at 11:56 PM]
why do you need to check?