|
楼主 |
发表于 2020-4-16 18:44
|
显示全部楼层
客户名称模糊搜索,输入 客户代码 或客户名称 任意关键字皆可:
将列表属性设置成2 列: ListBox2.ColumnCount = 2
- Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
- Dim i As Integer, j As Integer
- Dim myStr As String
- On Error Resume Next
- Me.ListBox2.Clear
- With Me.TextBox2
- For i = 1 To Len(.Value)
- myStr = myStr & LCase(Mid$(.Value, i, 1))
- Next
- End With
- For i = 2 To UBound(crr)
- If InStr(crr(i, 2), myStr) Or InStr(crr(i, 3), myStr) Then
- Me.ListBox2.AddItem crr(i, 2)
- Me.ListBox2.List(j, 1) = crr(i, 3)
- j = j + 1
- End If
- Next
- End Sub
- Private Sub ListBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
- On Error Resume Next
- If KeyCode = vbKeyReturn Then
- ActiveCell.Value = ListBox2.List(ListBox2.ListIndex, 1) 'ListBox2.Value
- [b4].Select
- Me.ListBox2.Clear
- Me.TextBox2 = ""
- Me.ListBox2.Visible = False
- Me.TextBox2.Visible = False
- End If
- End Sub
- Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
- On Error Resume Next
- ActiveCell.Value = ListBox2.List(ListBox2.ListIndex, 1) 'ListBox2.Value
- [b4].Select
- Me.ListBox2.Clear
- Me.TextBox2 = ""
- Me.ListBox2.Visible = False
- Me.TextBox2.Visible = False
- End Sub
复制代码
改产品名称全表检索,关键字可为: 产品代码、名称、规格型号、颜色 任一关键字,
将代码中:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
..........
For i = 1 To UBound(Arrsj)
If InStr(Arrsj(i, 2), myStr) Then
j = j + 1
改成:
For i = 1 To UBound(Arrsj)
If InStr(Arrsj(i, 1), myStr) Or InStr(Arrsj(i, 2), myStr) Or InStr(Arrsj(i, 4), myStr) Or InStr(Arrsj(i, 5), myStr) Then
j = j + 1
即可 |
评分
-
1
查看全部评分
-
|