如何从文本中搜索数据以在组合中显示结果 [英] How to search data from text to show result in combo
问题描述
Private Sub Combo14_LostFocus()
Dim x() As String
x = Split(Text2.Text, " ")
If x(0) <> Empty Then
Combo14.Text = Text2.Text
If UBound(x) Then
Combo14.Text = x(0)
Else
If UBound(x) Then
Combo14.Text = x(1)
Else
If UBound(x) Then
Combo14.Text = x(2)
End If
End If
End If
End If
End Sub
Private Sub Text2_LostFocus()
If Text2.Text = Empty Then Exit Sub
Dim STR() As String
STR = Split(Text2.Text, " ")
If STR(0) <> Empty Then
Combo14.Text = STR(0)
End If
End Sub
此代码适用于以下操作:
从文本框(firstname-text2,middlename-text3,lastname-text4)拆分名称以将列表填充到组合框(combo14)和组合框应该只显示与输入到其他文本框中的名称相关的那些记录。在某种程度上,我将使用文本框作为搜索框。
与text2相同的代码,我为text3和text 4编写了
运行此代码组合框时显示所有记录(全名)。不是特定的文字相关的全名。
关于这一点,请帮助我。
我的观点是否被任何人都不理解??????
请尝试理解
Is this code suitable for the operation like:
Splitting names from text boxes(firstname-text2,middlename-text3,lastname-text4)to populate list into combo box(combo14) and combo box should show only those records related to the name entered into either of text boxes not other than them.In one way I am going to use text box as a search box.
Same code as text2,I have written for text3 and text 4
While running this code combo box shows all the records(full-names). Not the specific text related full-names.
Please help me regarding this point.
Whether my point is not understood by anybody??????
please try to understand
推荐答案
If x(0) <> Empty Then
Combo14.Text = Text2.Text
If UBound(x) Then
Combo14.Text = x(0)
Else
If UBound(x) Then
Combo14.Text = x(1)
Else
If UBound(x) Then
Combo14.Text = x(2)
End If
以上序列没有多大意义。如果原始字符串中至少有一个单词,则将组合框的 Text
项设置为完整字符串。然后检查数组中是否有多个子字符串,如果是,则尝试将其设置为每三个单独的项目。
查看文档 [ ^ ]检查你想做什么。
The above sequence does not make much sense. If there is at least one word in your original string then you set the Text
item of the combo box to the complete string. You then check if there is more than 1 substring in the array, and if so you try to set it to each three separate items.
Take a look at the documentation[^] to check what you want to do.
这篇关于如何从文本中搜索数据以在组合中显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!