code,allows,autocomplete,function,text,boxes,
Quick Search for:  in language:    
code,allows,autocomplete,function,text,boxes,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
RentACoder Stats

 Code:  lines
 Jobs: 0 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for RentACoder.
Password generator which makes getting password without knowing it even with code hard.
By jokuvaan on 7/3


Wrapping Scrolling Text
By Paranoid_Androi d on 7/2


Create A Dummy File
By AML on 7/2


Click here to see a screenshot of this code!Captionbar manipulation!
By Peter Hebels on 7/2

(Screen Shot)

A Game Of War
By Co0nest on 7/2


Click here to see a screenshot of this code!KeyGen Example
By Bengie|NET on 7/2

(Screen Shot)

Click here to see a screenshot of this code!OpenBrowser v1.9
By Orlando Jerez on 7/2

(Screen Shot)

SendMessageBySt ring() Example
By Jaime Muscatelli on 7/2


Click here to see a screenshot of this code!FirstSunday
By Jan Paul Penning on 7/2

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

AutoCompleter - Class Module

Print
Email
 
VB icon
Submitted on: 10/17/1999
By: dmbbob 
Level: Not Given
User Rating: By 103 Users
Compatibility:

Users have accessed this code 7336 times.
 
 
     This code allows you to have an autocomplete function on any text boxes by creating an instance of the class module below and setting a text control on a form to is CompleteTextbox property. Ideal for those situations when you have multiple autocompletes. (Visual Basic 6 Only - Can easily be modified for 5.0 users)
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: AutoCompleter - Class Module
    // Description:This code allows you to h
    //     ave an autocomplete function on any text
    //     boxes by creating an instance of the cla
    //     ss module below and setting a text contr
    //     ol on a form to is CompleteTextbox prope
    //     rty. Ideal for those situations when you
    //     have multiple autocompletes. (Visual Bas
    //     ic 6 Only - Can easily be modified for 5
    //     .0 users)
    // By: dmbbob
    //
    // Inputs:
    Dim m_objAutoCompleteUser as clsAutoComplete
    Set m_objAutoCompleteUser = New clsAutoComplete
    With m_objAutoCompleteUser
    .SearchList = m_strUserList
    Set .CompleteTextbox = txtUser
    .Delimeter = ","
    End With
    //
    // Assumes:Create a new class module.
    Paste all the code below into it.
    Rename the module to clsAutoComplete.
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.4073/lngWId.-10/qx/vb/scripts/ShowCo
    //     de.htm    //for details.    //**************************************
    //     
    
    Option Explicit
    Private WithEvents m_txtComplete As TextBox
    Private m_strDelimeter As String
    Private m_strList As String
    Private Sub m_txtComplete_KeyUp(KeyCode As Integer, Shift As Integer)
    Dim i As Integer
    Dim strSearchText As String
    Dim intDelimented As Integer
    Dim intLength As Integer
    Dim varArray As Variant
    With m_txtComplete
    If KeyCode <> vbKeyBack And KeyCode > 48 Then 
    If InStr(1, m_strList, .Text, vbTextCompare) <> 0 Then
    varArray = Split(m_strList, m_strDelimeter)
    For i = 0 To UBound(varArray)
    strSearchText = Trim(varArray(i))
    If InStr(1, strSearchText, .Text, vbTextCompare) And
    (Left$(.Text, 1) = Left$(strSearchText, 1)) And 
    .Text <> "" Then
    .SelText = ""
    .SelLength = 0
    intLength = Len(.Text)
    .Text = .Text & Right$(strSearchText, Len(strSearchText) - Len(.Text))
    .SelStart = intLength
    .SelLength = Len(.Text)
    Exit Sub
    End If
    Next i
    End If
    End If
    End With
    End Sub
    Public Property Get CompleteTextbox() As TextBox
    Set CompleteTextbox = m_txtComplete
    End Property
    Public Property Set CompleteTextbox(ByRef txt As TextBox)
    Set m_txtComplete = txt
    End Property
    Public Property Get SearchList() As String
    SearchList = m_strList
    End Property
    Public Property Let SearchList(ByVal str As String)
    m_strList = str
    End Property
    Public Property Get Delimeter() As String
    Delimeter = m_strDelimeter
    End Property
    Public Property Let Delimeter(ByVal str As String)
    m_strDelimeter = str
    End Property

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
11/11/1999 8:18:00 PM:STEPPA
Kewl code but I can't get it to 
work...Any ideas?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/11/1999 8:34:00 PM:dmbbob
Well are you using VB 6.0?  If so, 
could you tell me where you're having 
problems...Maybe I can help.  You 
should be able to pop it right 
in....
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/21/1999 11:43:00 AM:Fredrik Stai
If someone could just take some minutes 
making a VB5-version of this code and 
post it to PlanetSourceCode.. (c;
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/22/1999 9:08:00 AM:dmbbob
The only thing this code needs to work 
with VB5 is something that resembled 
the split function in VB6.  Search for 
Jean-Philippe Leconte's split function 
listed on Planet Source Code.  Paste 
the function into this class module.  
Suggestion: Change the function 
from Public to Private to hide it from 
the calling objects.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/30/1999 2:23:00 AM:Atique
I could not find it work. I am using 
VB6. I want to know what to write in 
form and what controls to put on the 
form.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/30/1999 12:35:00 PM:dmbbob
On a form you should have a textbox 
that you'd like to have autocomplete.  
In the form you should do the 
following in the Form_Load() 
event.
Set m_objAutoCompleteUser = 
New clsAutoComplete
With 
m_objAutoCompleteUser
    .SearchList 
= m_strUserList
    Set 
.CompleteTextbox = Text1
.Delimeter = ","
End With
As a 
global declarartion within the 
form
Dim m_objAutoCompleteUser as 
clsAutoComplete
Should work fine...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/29/2000 4:15:17 PM:todd
dmbbob: i know that you pasted in a 
feedback, but just a sugestion, change 
the code in the submission so that when 
users copy it, they will under stand 
that 
"Dim m_objAutoCompleteUser As 
clsAutoComplete" must be in the 
(General) Declarations section.
BTW: 
this is the BEST BEST Autocomplete i 
have seen.  the way you have it just 
parsing a string is perfect for 
performance...
im impressed  
=)
thanks for the code
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/30/2000 11:30:35 AM:DarkDraco
I'm probably going to sound Thick but 
oh well,
i can't get this thing to 
work, whatever i type in the box doesnt 
get auto competed if i retype it in the 
same session...
after running the 
code line by line, i noticed that 
"m_strList" is always empty, meaning 
that "If InStr(1, m_strList, .Text, 
vbTextCompare) <> 0" is never valid and 
therefore never enters in the if.
i 
was wondering, do i need to add code to 
fill an array or to set a value to 
"m_strList" whenever i type 
something?
or should this code work 
by itself with nothing to be 
added?
also, is it possible that to 
put this code into an activeX control 
would require a complete rewrite of the 
code?
im thinking that it probably 
does since it doesnt let you define 
"Public Property Get CompleteTextbox() 
As TextBox" because TextBox is a 
private object type
but im not shure
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/16/2000 5:39:43 PM:Programmer411
I don't know what I'm doing wrong!
I 
copied the code into the class module 
(clsAutoComplete) and I added 
Dim 
m_objAutoCompleteUser As 
clsAutoComplete
to form load and the 
general declarations sections.  I also 
placed a txtbox (txtAuto) on the 
form.
What's keeping this from 
working?
>>Programmer411
>>Marztek 
Software
>>Marztek.itgo.com
>>webmaste
r@marztek.itgo.com
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/17/2000 9:11:05 AM:dmbbob
The object should be declared as a 
global object within the Form Module.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/17/2000 9:12:13 AM:dmbbob
Darn...this is cutting off my 
text...lemme try again....
The object 
should be declared as a global object 
within the Form Module.  
Option 
Explict
Dim m_objAutoCompleteUser as 
clsAutoComplete
Within the 
Form_Load() event you'll set up the 
object like this:
Private Sub 
Form_Load()
   Set 
m_objAutoCompleteUser = New 
clsAutoComplete
   With 
m_objAutoCompleteUser
.SearchList = m_strUserList
      Set 
.CompleteTextbox = txtUser
.Delimeter = ","
   End With
End 
Sub
Give it a shot...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/19/2000 9:00:13 PM:liliafan
I am getting an error here 
Error 
"459" object does not support 
events
Public Property Set 
CompleteTextbox(ByRef txt As 
TextBox)
Set m_txtComplete = txt
End 
Property
Any ideas what I am doing 
wrong?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/28/2000 2:00:53 PM:Darrin
This code looks awesome, and I would 
love to use it, but I can't figure out 
where it gets the key to match up to 
the list of items??? Does there need to 
be someting in the keypress event for 
that particular txtbox?? Please help. 
Thank you in advance!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/29/2000 11:04:54 AM:dmbbob
I trap the events of the textbox using 
the 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/19/2000 9:50:41 AM:Cape
The Code is excelente, but if you 
change this part:
-----------        
If InStr(1, strSearchText, .Text, 
vbTextCompare) And (Left$(.Text, 1) = 
Left$(strSearchText, 1)) And .Text <> 
"" Then
-----------------
by 
this:
-----------        
If InStr(1, 
strSearchText, .Text, vbTextCompare) 
And (.Text = Left$(strSearchText, 
len(.text))) And .Text <> "" 
Then
-----------------
will be 
better.
Thanx for the code.!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/13/2001 12:48:36 AM:Terrell Davis
In order for your routine to be case 
insensitive you need to modify this 
line:
If InStr(1, strSearchText, 
.Text, vbTextCompare) And
   (Left$(.Text, 1) = 
Left$(strSearchText, 1)) And 
       .Text <> 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | RentACoder Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.