|
-
May 21st, 2004, 12:07 PM
#1
In the IDE?
In VB6, I use this little nugget to tell whether or not I am running inside the IDE...
VB Code:
Private Function InIDE() As Boolean
On Error GoTo ReturnTrue
Debug.Print (1 / 0)
InIDE = False
Exit Function
ReturnTrue:
InIDE = True
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
-
May 21st, 2004, 12:13 PM
#2
Hyperactive Member
I would use the same the same concept but use Assert instead of Print
VB Code:
Private Function InIDE() As Boolean
On Error GoTo ReturnTrue
Debug.Assert (0 = 1)
InIDE = False
Exit Function
ReturnTrue:
InIDE = True
End Function
-
May 21st, 2004, 12:17 PM
#3
Hyperactive Member
Sorry, I should have tested that before I posted it. That does not work.
-
May 21st, 2004, 12:31 PM
#4
Hyperactive Member
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:
#If InIDE Then
'put code for what you want to do if you are in the ide here
#Else
'put code for what you want to do other wise here
#End If
This works, I took the time to test it before I posted.
-
May 21st, 2004, 12:35 PM
#5
Thanks, I just found this one, too, and it doesn't require remembering to change constants...
VB Code:
Private Function InIDE() As Boolean
Return Debugger.IsAttached
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|