需要两个空间 combo1 text1注意:只读属性 combo1.Style 值 要改为 2代码如下:Private Sub Form_Load() '初始化combo1里的菜单项 测试时候用 Combo1.AddItem "11" Combo1.AddItem "22" Combo1.AddItem "33" Combo1.AddItem "44" Combo1.AddItem "55" combo1. End SubPrivate Sub Text1_Change() On Error Resume Next '忽略错误,不能少 Combo1.Text = Text1.Text End Sub这个方法实现起来 比 timer控件 方便的多
直流只用一个COMBOBOX就够了: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 Sub Combo1_Change() Dim iStart As Integer Dim sString As String Static iLeftOff As Integer
If Combo1.ListIndex = -1 Then iLeftOff = Len(sString): Combo1.Text = sString If Combo1.Text <> "" Then SendMessage Combo1.hwnd, &H14F, True, 0Combo1.SelStart = iStart Combo1.SelLength = 0 iLeftOff = 0End Sub Private Sub Form_Load() Dim i As Long For i = 1 To 500 Randomize Combo1.AddItem Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) Next Combo1.Text = "" End Sub
一旦text有新的东西,就自动加上
'初始化combo1里的菜单项 测试时候用
Combo1.AddItem "11"
Combo1.AddItem "22"
Combo1.AddItem "33"
Combo1.AddItem "44"
Combo1.AddItem "55"
combo1.
End SubPrivate Sub Text1_Change()
On Error Resume Next '忽略错误,不能少
Combo1.Text = Text1.Text
End Sub这个方法实现起来 比 timer控件 方便的多
Private Sub Combo1_Change()
Dim iStart As Integer
Dim sString As String
Static iLeftOff As Integer
iStart = 1
iStart = Combo1.SelStart
If iLeftOff <> 0 Then Combo1.SelStart = iLeftOff: iStart = iLeftOffsString = CStr(Left(Combo1.Text, iStart))
Combo1.ListIndex = SendMessage(Combo1.hwnd, &H14C, -1, ByVal CStr(Left(Combo1.Text, iStart)))
If Combo1.ListIndex = -1 Then iLeftOff = Len(sString): Combo1.Text = sString
If Combo1.Text <> "" Then SendMessage Combo1.hwnd, &H14F, True, 0Combo1.SelStart = iStart
Combo1.SelLength = 0
iLeftOff = 0End Sub
Private Sub Form_Load()
Dim i As Long
For i = 1 To 500
Randomize
Combo1.AddItem Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97)
Next
Combo1.Text = ""
End Sub