奇怪的VB问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 07:12:31
form里面加个text2控件,然后If Text2.Text = "q" Then 'q-key 存盘
Dim swApp As Object
Dim Part As Object
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Part.ShowNamedView2 "*等轴测", 7
Part.Save2 False
Form1.Show
Form1.ZOrder 1
Text2.Text = ""
End If

这段程序是存盘用的

上面一段程序可以通过使用

在模块里面加:
Option Explicit

Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim ReturnValue, i

Public Const WH_KEYBOARD = 13
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As

Dim swApp As Object
Dim Part As Object
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Part.ShowNamedView2 "*等轴测", 7
Part.Save2 False
Form1.Show
Form1.ZOrder 1
Text2.Text = ""
End If
哪里来的 end if???

检查有没有编错代码
比如与调用相关的代码写错了

为什么要用模块呢?