VB IDEAdd code to a Module


Determine if an application is running in the VB IDEAdd this code to a Module:

Option Explicit

Declare Function GetModuleFileName Lib “KERNEL32” Alias _
“GetModuleFileNameA” (ByVal hModule As Long, ByVal lpFileName As String, _
ByVal nSize As Long) As Long

Public Function DebugMode() As Boolean
Dim strFileName As String
Dim lngCount As Long
strFileName = String(255, 0)
lngCount = GetModuleFileName(App.hInstance, strFileName, 255)
strFileName = Left(strFileName, lngCount)
If UCase(Right(strFileName, 7)) <> “VB6.EXE” Then
DebugMode = False
Else
DebugMode = True
End If
End Function

‘– End –‘

To use the function just add the following code in code:

If DebugMode Then
‘ Running in the VB IDE
Else
‘ Run

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s