Debug Mode In VB 6?

前端 未结 4 1014
南方客
南方客 2021-02-18 13:33

How can I do something similar to the following C code in VB 6?

#ifdef _DEBUG_
    // do things
#else
    // do other things
#end if
4条回答
  •  醉梦人生
    2021-02-18 14:00

    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.

提交回复
热议问题