| | |
searching help part 2..
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 141
Reputation:
Solved Threads: 15
I understand what you mean, like an autocomplete text field so as you're typing, it will attempt to finish off what you're typing to the nearest match?
I have found something on another site, but as I'm unsure that I can link to an external forum, I'll quote it from the other site but won't direct link.
Hope that is what you're after
I have found something on another site, but as I'm unsure that I can link to an external forum, I'll quote it from the other site but won't direct link.
•
•
•
•
Originally Posted by Danial @ VBForums
Here is little snippet I put together for a project that will give you Auto Complete feature in your Project. Simply Place a Combo Box named cmbInput and add a reference to "Microsoft Scripting Runtime".
Note that I only used FSO to load some sample(I am loading all the folder name from C:\program files) item to the combo box, you can add any item you wish.
Finally, i am looping through all Item to find the match, if I use API it might be faster. I will see if I can speed it up in future when I get a chance.
Enjoy
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Private Sub cmbInput_KeyUp(KeyCode As Integer, Shift As Integer) AutoSel cmbInput, KeyCode End Sub Private Sub Form_Load() Dim FolderPath As String FolderPath = "C:\Program Files" Dim Folder Dim File Dim FSO As New Scripting.FileSystemObject Set Folder = FSO.GetFolder(FolderPath) Dim f For Each f In Folder.SubFolders cmbInput.AddItem f.Name Next End Sub Function AutoSel(Cmb As ComboBox, KeyCode As Integer) Debug.Print KeyCode If KeyCode = vbEnter Then Exit Function If KeyCode = 8 Then Exit Function 'Backspace If KeyCode = 37 Then Exit Function 'left key If KeyCode = 38 Then Exit Function 'up arrow key If KeyCode = 39 Then Exit Function 'right key If KeyCode = 40 Then Exit Function 'down arrow key If KeyCode = 46 Then Exit Function 'delete key If KeyCode = 33 Then Exit Function 'page up key If KeyCode = 34 Then Exit Function 'page down key If KeyCode = 35 Then Exit Function 'end key If KeyCode = 36 Then Exit Function 'home key Dim Text As String Text = Cmb.Text Dim i As Long Dim Temp As String For i = 0 To Cmb.ListCount Temp = Left(Cmb.List(i), Len(Text)) If LCase(Temp) = LCase(Text) Then Cmb.Text = Cmb.List(i) Cmb.ListIndex = i Cmb.SelStart = Len(Text) Cmb.SelLength = Len(Cmb.List(i)) 'Cmb.SetFocus End If Next End Function
Hope that is what you're after
Last edited by jonifen; Jan 29th, 2008 at 4:25 am.
•
•
Join Date: Nov 2007
Posts: 141
Reputation:
Solved Threads: 15
Oh, you're using Access (VBA) rather than VB6?
I didn't know this when posting... the source I found on the site (and quoted above) was for actual VB6 which would explain your problem.
One thing to check though... have you added the reference to "Microsoft Scripting Runtime" in your database?
The following quoted line of code is attempting to create a new instance of an FSO object, but it will fail if the reference is not made to the DLL which holds this object.
Info you may not need but I've included to be on the safe side
If I remember right, when in Access, open up any code module (an actual module or the code window for a form) and go to "Tools" menu at the top and then "References". You would need to ensure that the Scripting runtime one is ticked before anything with FSO/FileSystemObjects will work.
I didn't know this when posting... the source I found on the site (and quoted above) was for actual VB6 which would explain your problem.
One thing to check though... have you added the reference to "Microsoft Scripting Runtime" in your database?
The following quoted line of code is attempting to create a new instance of an FSO object, but it will fail if the reference is not made to the DLL which holds this object.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim FSO As New Scripting.FileSystemObject
Info you may not need but I've included to be on the safe side

If I remember right, when in Access, open up any code module (an actual module or the code window for a form) and go to "Tools" menu at the top and then "References". You would need to ensure that the Scripting runtime one is ticked before anything with FSO/FileSystemObjects will work.
![]() |
Similar Threads
- Searching for a great SE person with other Marketing Skills as well (Internet Marketing Job Offers)
- Searching for a record in multiple tables (VB.NET)
- organizing programs (Windows NT / 2000 / XP)
- Searching and Comparing strings from an XML Document (Python)
- Searching my web page (PHP)
- Searching Function at listview by using VB.Net (VB.NET)
- FULLTEXT searching (MySQL)
- multiple file searching (C)
- deleting from a database (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: how to insert records into a table using datacontrol
- Next Thread: error problem.
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





