|
-
May 28th, 2000, 03:53 AM
#1
Thread Starter
Frenzied Member
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.
-
May 28th, 2000, 10:39 AM
#2
Sorry Sam maybe you could explain a bit more
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
-
May 28th, 2000, 10:45 AM
#3
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?
-
May 29th, 2000, 09:06 AM
#4
Addicted Member
Here is my Idea !
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
-
May 29th, 2000, 01:00 PM
#5
Hyperactive Member
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!
-
May 29th, 2000, 03:47 PM
#6
Hyperactive Member
Here's something that does work....
OK Declare this:
Code:
Private Declare Function GetModuleFileName Lib "kernel32" _
Alias "GetModuleFileNameA" (ByVal hModule As Long, _
ByVal lpFileName As String, ByVal nSize As Long) As Long
then use...
Code:
'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
A little clumsy, but it works 

Dan
-
May 29th, 2000, 05:07 PM
#7
Thread Starter
Frenzied Member
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.
-
May 29th, 2000, 05:12 PM
#8
shouldn't UserControl.Ambient.UserMode do the trick ?
-
May 29th, 2000, 07:16 PM
#9
Thread Starter
Frenzied Member
No, that says if the parent is at design time or run time.
-
May 29th, 2000, 08:54 PM
#10
Addicted Member
This should work !
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
-
May 30th, 2000, 10:54 AM
#11
Addicted Member
Is this Working or not ??
Hey, I need feedback guys,
Did this code work or not ?
[Edited by G.Kumaraguru on 05-30-2000 at 11:56 PM]
-
May 30th, 2000, 11:04 AM
#12
Conquistador
why do you need to check?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|