searching help part 2..

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

searching help part 2..

 
0
  #1
Jan 29th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 142
Reputation: jonifen is an unknown quantity at this point 
Solved Threads: 15
jonifen jonifen is offline Offline
Junior Poster

Re: searching help part 2..

 
1
  #2
Jan 29th, 2008
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.

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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: searching help part 2..

 
0
  #3
Jan 29th, 2008
theirs an error on this code..

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

thxxxxxxxx
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 142
Reputation: jonifen is an unknown quantity at this point 
Solved Threads: 15
jonifen jonifen is offline Offline
Junior Poster

Re: searching help part 2..

 
0
  #4
Jan 29th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: searching help part 2..

 
0
  #5
Jan 29th, 2008
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..
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 142
Reputation: jonifen is an unknown quantity at this point 
Solved Threads: 15
jonifen jonifen is offline Offline
Junior Poster

Re: searching help part 2..

 
0
  #6
Jan 30th, 2008
No problem, glad to have been of help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1205 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC