model
實(shí)現(xiàn)輸入號(hào)碼就產(chǎn)生聯(lián)想的功能
Private Sub ListBox1_Click()
'下拉框的值被點(diǎn)擊時(shí)顯示至文本框'
Me.TextBox1.Value = Me.ListBox1.Value
'選擇好值后隱藏下拉框'
Me.ListBox1.Visible = False
End Sub
Private Sub TextBox1_Change()
'如果輸入的數(shù)字大于4位'
If Len(Me.TextBox1.Value) >= 4 Then
'每次循環(huán)前清空列表框'
Me.ListBox1.Clear
For i = 2 To 8
If InStr(Sheet1.Range("i" & i), Me.TextBox1.Value) > 0 Then
Me.ListBox1.AddItem Sheet1.Range("i" & i)
End If
Next
'列表框中的數(shù)量大于0才顯示'
If Me.ListBox1.ListCount > 0 Then
Me.ListBox1.Visible = True
Else
Me.ListBox1.Visible = False
End If
'循環(huán)完后顯示下拉框中的內(nèi)容'
Me.ListBox1.Visible = True
Else
'輸入的數(shù)字時(shí)<= 4時(shí)不顯示'
Me.ListBox1.Visible = False
End If
End Sub
Private Sub CommandButton1_Click()
Dim rng As Range
'用find方法做
Set rng = Sheet1.Range("i1:i1000").Find(Me.TextBox1.Value)
If rng Is Nothing Then
MsgBox "無該用戶"
Else
Me.Label2.Caption = rng.Offset(0, -6)
Me.Label4.Caption = rng.Offset(0, -5)
Me.Label6.Caption = rng.Offset(0, -4)
Me.Label8.Caption = rng
Me.Label10.Caption = rng.Offset(0, -3)
Me.Label11.Caption = rng.Offset(0, -2)
Me.Label12.Caption = rng.Offset(0, -1)
End If
End Sub
Private Sub ListBox1_Click()
'下拉框的值被點(diǎn)擊時(shí)顯示至文本框'
Me.TextBox1.Value = Me.ListBox1.Value
'選擇好值后隱藏下拉框'
Me.ListBox1.Visible = False
End Sub
Private Sub TextBox1_Change()
'如果輸入的數(shù)字大于4位'
If Len(Me.TextBox1.Value) >= 4 Then
'每次循環(huán)前清空列表框'
Me.ListBox1.Clear
For i = 2 To 8
If InStr(Sheet1.Range("i" & i), Me.TextBox1.Value) > 0 Then
Me.ListBox1.AddItem Sheet1.Range("i" & i)
End If
Next
'列表框中的數(shù)量大于0才顯示'
If Me.ListBox1.ListCount > 0 Then
Me.ListBox1.Visible = True
Else
Me.ListBox1.Visible = False
End If
'循環(huán)完后顯示下拉框中的內(nèi)容'
Me.ListBox1.Visible = True
Else
Me.ListBox1.Clear
'輸入的數(shù)字時(shí)<= 4時(shí)不顯示'
Me.ListBox1.Visible = False
End If
End Sub