Results 1 to 2 of 2

Thread: Text Box

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    Is it possible to have a intellisense like feature in a text box?
    I have a list of users, 35 of them. I want them to type their name in the text box first name followed by last name,ie "Mike Daugird"
    I am the only Mike in the list. When I finish typing Mike It would be nice for it to add Daugird so that I can just tab to the next box.
    Is it possible? Does anyone have any ideas? Is there a different control which is better at doing what I want?
    thank you for your time and have a good day

    ------------------
    I am so skeptacle, I can hardly believe it!

  2. #2
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    I would reccomend using a cobobox and use MS's standard Auto complete

    Code:
    Option Explicit
    
    Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
    
    Private Const CB_FINDSTRING = &H14C
    Private Const CB_ERR = (-1)
    
    Private Declare Function PostMessage Lib "user32" Alias _
    "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Private Const CB_SETCURSEL = &H14E
    Private m_bEditFromCode As Boolean
    
    
    Private Sub Form_Load()
    
    With Combo1
      .AddItem "VB Square"
      .AddItem "http://www.vbsquare.com"
      .AddItem "VB World"
      .AddItem "http://www.vb-world.net"
    End With
    
    End Sub
    
    Private Sub Combo1_Change()
    Dim i As Long, j As Long
    Dim strPartial As String, strTotal As String
    If m_bEditFromCode Then
    m_bEditFromCode = False
    Exit Sub
    End If
    
    With Combo1
    
    strPartial = .Text
    i = SendMessage(.hwnd, CB_FINDSTRING, -1, ByVal strPartial)
    
    If i <> CB_ERR Then
      strTotal = .List(i)
      j = Len(strTotal) - Len(strPartial)
      If j <> 0 Then
        m_bEditFromCode = True
        .SelText = Right$(strTotal, j)
        'Select unmatched characters
        .SelStart = Len(strPartial)
        .SelLength = j
      Else
      End If
    End If
    End With
    
    End Sub
    
    Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    
    Select Case KeyCode
    Case vbKeyDelete
      m_bEditFromCode = True
    Case vbKeyBack
      m_bEditFromCode = True
    End Select
    
    End Sub
    [This message has been edited by Inhumanoid (edited 01-06-2000).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width