Results 1 to 12 of 12

Thread: is a program in debug mode?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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.

  2. #2
    Guest

    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

  3. #3
    Guest
    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?

  4. #4
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224

    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

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318

    Unhappy

    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!



  6. #6
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking 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

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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.


  8. #8
    Guest
    shouldn't UserControl.Ambient.UserMode do the trick ?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    No, that says if the parent is at design time or run time.

  10. #10
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224

    Talking 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


  11. #11
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224

    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]

  12. #12
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    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
  •  



Click Here to Expand Forum to Full Width