How can I do something similar to the following C code in VB 6?
#ifdef _DEBUG_
// do things
#else
// do other things
#end if
To achieve the same effect as MarkJ, but with error handling, you can use the following code.
Public Function GetRunningInIDE() As Boolean
Dim x As Long
Debug.Assert Not TestIDE(x)
GetRunningInIDE = x = 1
End Function
Private Function TestIDE(x As Long) As Boolean
x = 1
End Function
When you are running from within the IDE, there will be an extra overhead of calling a function (which is ridiculously small). When compiled, this evaluates to a simple number comparison.