为什么StripTerFlag函数没定义,但是执行时会出错呢,请问该怎么解决?

'创建一个列表框和一个按钮
'API函数定义
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Sub Command1_Click()
Dim s As Long
Dim a As String
a = Space(255)
s = GetWindow(Me.hwnd, GW_HWNDFIRST) '获得句柄
GetWindowText s, a, 255 '获得标题
Dim ab As String * 255
GetClassName s, ab, 255 '获得类名
Dim ClassName As String
ClassName = StripTerFlag(ab) 'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符
If UCase(ClassName) = "NOTEPAD" Then
List1.AddItem a
List1.ItemData(List1.ListCount - 1) = s
End If
Do While s
DoEvents
s = GetWindow(s, GW_HWNDNEXT) '获得句柄
GetWindowText s, a, 255 '获得标题
GetClassName s, ab, 255 '获得类名
ClassName = StripTerFlag(ab)
If UCase(ClassName) = "NOTEPAD" Then
List1.AddItem a
List1.ItemData(List1.ListCount - 1) = s
End If
Loop
End Sub
Private Sub List1_Click()
MsgBox List1.ItemData(List1.ListIndex) '单击列表框获得句柄
End Sub

慕神8447489
浏览 334回答 1
1回答

阿波罗的战车

ClassName = StripTerFlag(ab) 'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符你是不是把这个StripTerFlag过程代码放到模块中 而这个过程是Private私有过程 修改成public公用即可
打开App,查看更多内容
随时随地看视频慕课网APP