943,791 Members | Top Members by Rank

Ad:
Jan 29th, 2008
0

searching help part 2..

Expand Post »
i would like to make a search textbox that will automatically searchh the data and droping down the txtbox... like in the member search of this site...

pleaseeeeeeee.. kindly give me some code.. to make that...
sorry for the previous thread.

jaasaria
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Jan 29th, 2008
1

Re: searching help part 2..

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.

Quote 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)
  1. Option Explicit
  2.  
  3. Private Sub cmbInput_KeyUp(KeyCode As Integer, Shift As Integer)
  4. AutoSel cmbInput, KeyCode
  5. End Sub
  6.  
  7. Private Sub Form_Load()
  8.  
  9. Dim FolderPath As String
  10. FolderPath = "C:\Program Files"
  11.  
  12. Dim Folder
  13. Dim File
  14.  
  15. Dim FSO As New Scripting.FileSystemObject
  16.  
  17. Set Folder = FSO.GetFolder(FolderPath)
  18.  
  19. Dim f
  20.  
  21.  
  22. For Each f In Folder.SubFolders
  23. cmbInput.AddItem f.Name
  24. Next
  25.  
  26. End Sub
  27.  
  28. Function AutoSel(Cmb As ComboBox, KeyCode As Integer)
  29.  
  30. Debug.Print KeyCode
  31.  
  32. If KeyCode = vbEnter Then Exit Function
  33. If KeyCode = 8 Then Exit Function 'Backspace
  34. If KeyCode = 37 Then Exit Function 'left key
  35. If KeyCode = 38 Then Exit Function 'up arrow key
  36. If KeyCode = 39 Then Exit Function 'right key
  37. If KeyCode = 40 Then Exit Function 'down arrow key
  38. If KeyCode = 46 Then Exit Function 'delete key
  39. If KeyCode = 33 Then Exit Function 'page up key
  40. If KeyCode = 34 Then Exit Function 'page down key
  41. If KeyCode = 35 Then Exit Function 'end key
  42. If KeyCode = 36 Then Exit Function 'home key
  43.  
  44.  
  45. Dim Text As String
  46. Text = Cmb.Text
  47.  
  48. Dim i As Long
  49. Dim Temp As String
  50.  
  51. For i = 0 To Cmb.ListCount
  52. Temp = Left(Cmb.List(i), Len(Text))
  53. If LCase(Temp) = LCase(Text) Then
  54. Cmb.Text = Cmb.List(i)
  55. Cmb.ListIndex = i
  56. Cmb.SelStart = Len(Text)
  57. Cmb.SelLength = Len(Cmb.List(i))
  58. 'Cmb.SetFocus
  59. End If
  60. Next
  61.  
  62. End Function

Hope that is what you're after
Last edited by jonifen; Jan 29th, 2008 at 4:25 am.
Reputation Points: 13
Solved Threads: 17
Junior Poster
jonifen is offline Offline
152 posts
since Nov 2007
Jan 29th, 2008
0

Re: searching help part 2..

theirs an error on this code..

actually i use ms access on my database..
could any one post any suggestion.

thxxxxxxxx
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Jan 29th, 2008
0

Re: searching help part 2..

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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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.
Reputation Points: 13
Solved Threads: 17
Junior Poster
jonifen is offline Offline
152 posts
since Nov 2007
Jan 29th, 2008
0

Re: searching help part 2..

owss. im sorry. i did wrong.^_^
hehe... i miss that thing..

thxxxxxx a lot..

actually i use vb6 in my project but i only use access in my database ..if im not wrong.
actually i get the exact code.. but the code are to more..
they use the module for it..

thxxxxxxxx a lot..
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Jan 30th, 2008
0

Re: searching help part 2..

No problem, glad to have been of help.
Reputation Points: 13
Solved Threads: 17
Junior Poster
jonifen is offline Offline
152 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how to insert records into a table using datacontrol
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: error problem.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC