怎么设置combo1的出现下拉关联
发布网友
发布时间:2022-04-25 22:29
我来回答
共2个回答
热心网友
时间:2022-06-18 04:38
在combo控件的change事件中用dir 搜索含combo1.text文字的文件
热心网友
时间:2022-06-18 04:38
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_SHOWDROPDOWN = &H14F
Private Sub Combo1_Change()
Dim t As String, s As String, k As String, n As Long
Static Sc As Boolean
If Sc Then Exit Sub
Sc = True
With Combo1
t = .Text
n = .SelStart
'k 的值改成你需要的路径
k = "C:\Documents and Settings\user\桌面\soDesktop\book\BOOK\《DirectX+游戏开发终极指南》exe电子书+网页版\《DirectX 游戏开发终极指南》TXT 自整理版\"
.Clear
s = Dir(k & t & "*.txt")
While Len(s)
.AddItem s
s = Dir
Wend
.Text = t
.SelStart = n
SendMessage .hwnd, CB_SHOWDROPDOWN, -1, -1
Me.Refresh
End With
Sc = False
End Sub