If App.LogMode = 0 Then
MsgBox "ide环境中"
Else
MsgBox "非ide环境中"
End If
这个更简单,就是看不懂原理
http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763104c8c711923d030678197027fa3c215cc7911124d63feeb797f451988832b381ca8420bbca43571370574b391c88f1b8cea927c798d2d60720b8636489546f1df037881769f1eb9b81996ad813584d8d0c4af5044bb27127af1abdd0d1714bb7886122692d68e3e174866b8&p=9c3fd216d9c257e744bd9b7d0c7a&user=baidu
Option Explicit
Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Public Function GetIDEmode() As Boolean '是否运行在VB IDE编辑模式1
Dim strFileName As String
Dim lngCount As Long
strFileName = String(255, 0)
lngCount = GetModuleFileName(App.hInstance, strFileName, 255)
strFileName = Left(strFileName, lngCount)