Click here to Skip to main content
12,297,612 members (25,789 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB6 Oracle
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

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
Posted 31-Dec-12 19:38pm
surkhi623
Edited 31-Dec-12 23:05pm
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100