Results 1 to 5 of 5

Thread: In the IDE?

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    In the IDE?

    In VB6, I use this little nugget to tell whether or not I am running inside the IDE...
    VB Code:
    1. Private Function InIDE() As Boolean
    2. On Error GoTo ReturnTrue
    3.  
    4.     Debug.Print (1 / 0)
    5.     InIDE = False
    6.     Exit Function
    7.    
    8. ReturnTrue:
    9.     InIDE = True
    10. End Function

    Is there a similar way to do it in the .NET IDE? (In any language really)

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    I would use the same the same concept but use Assert instead of Print
    VB Code:
    1. Private Function InIDE() As Boolean
    2. On Error GoTo ReturnTrue
    3.  
    4.     Debug.Assert (0 = 1)
    5.     InIDE = False
    6.     Exit Function
    7.    
    8. ReturnTrue:
    9.     InIDE = True
    10. End Function

  3. #3
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Sorry, I should have tested that before I posted it. That does not work.

  4. #4
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Ok, sorry for the bad post before,
    The way I know I am in the IDE is with #Constants

    in your declarations section type
    #Const InIDE = 1 'Change to 0 for when you don't want to execute code based on this value

    Then anywhere you want to test it you would type
    VB Code:
    1. #If InIDE Then
    2.     'put code for what you want to do if you are in the ide here
    3. #Else
    4.     'put code for what you want to do other wise here
    5. #End If

    This works, I took the time to test it before I posted.

  5. #5

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Thanks, I just found this one, too, and it doesn't require remembering to change constants...
    VB Code:
    1. Private Function InIDE() As Boolean
    2.     Return Debugger.IsAttached
    3. End Function

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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