devxlogo

Simulate an Outlook Address Book Records Selection

Simulate an Outlook Address Book Records Selection

This tip shows how to simulate the look of an Oultlook address book records selection.

  • Open a New VB Project and add a New Form with 1 Text Box and a List Box.
  • Copy this code and you are set to go:
  •  	Private Sub Text1_Change()	    	    Dim intI As Integer	    Dim strTmp As String	    	    strTmp = Text1.Text	    intI = MatchList(strTmp, List1) 'Call the Function	    	    If intI >= 0 Then	        List1.ListIndex = intI	        List1.TopIndex = intI	    End If	End Sub	Function MatchList(strIn As String, listIn As ListBox) As Integer	'------------------------------------------------------------	'Function to match the typed string from an existing list box	'NOTE : The list should be sorted	'------------------------------------------------------------	    Dim blnMatchFound As Boolean	    Dim intI As Integer	    Dim intstrLength As Integer	    Dim strFirstLetter As String	    	    intstrLength = Trim(Len(strIn))	    strFirstLetter = UCase(Left(Trim(strIn), 1))	    	    '*** Search for exact match ***	    For intI = 0 To listIn.ListCount - 1	     If Left(UCase(listIn.List(intI)), intstrLength) LikeUCase(strIn) Then	         blnMatchFound = True	         MatchList = intI	         Exit Function	     End If	    Next	    	    '*** Search for After/Before strings (if no match has beenfound) ***	    If blnMatchFound = False Then	        For intI = 0 To listIn.ListCount - 1	          If Left(UCase(listIn.List(intI)), 1) >UCase(strFirstLetter) Then	              blnMatchFound = True	              MatchList = intI	              Exit Function	          Else	              blnMatchFound = True	              MatchList = intI	          End If	        Next	    End If	    	End Function	Private Sub Form_Load()	    List1.AddItem
    
    devxblackblue

    About Our Editorial Process

    At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

    See our full editorial policy.

    About Our Journalist