|
-
Jul 28th, 2008, 12:46 PM
#1
Thread Starter
Junior Member
Searching Textboxes and Listboxes and dropdown lists
Well, im back again , arent u so happy? well anyway, i need a search that will search textboxes listboxes and dropdrown lists and return a list of Links that will hide and show textboxes
im guessing that this is possible, but i have no clue where to start, could somebody help me out a little, not write the whole script or anything (unless u wanna) but just give me a basis for the search
-
Jul 28th, 2008, 02:16 PM
#2
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
Where do you expect to get these textboxes, listboxes, or comboboxes from? I don't quite understand what you mind but it will return a list of links. Are you looking to say, look for all textboxes in your app and be able to hide them? Please be a bit more clear.
-
Jul 28th, 2008, 02:30 PM
#3
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
ok, i have a textbox with a submit button, i want the words inside the textboxed to be searched for from multiple textboxes, lisboxes, and comboboxes that i have hidden in my app and i want it to return a list of links that will show the textbox the word is in when clicked. make sense?
-
Jul 28th, 2008, 02:34 PM
#4
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
Yeah a bit. So all of the textboxes that you want to search FOR are in your app?
-
Jul 28th, 2008, 02:51 PM
#5
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
i want to search through, like lets say i have 5 articles, i want to find any mention of the word vista, so i type in vista and press submit, and it lists all the articles that have vista in it and i click on one and it takes me there
i already got the UI and search box done, i just need the code to search and display the results
-
Jul 28th, 2008, 03:05 PM
#6
Re: Searching Textboxes and Listboxes and dropdown lists
 Originally Posted by PHil_ROX
i want to search through, like lets say i have 5 articles, i want to find any mention of the word vista, so i type in vista and press submit, and it lists all the articles that have vista in it and i click on one and it takes me there
i already got the UI and search box done, i just need the code to search and display the results
You will find your code to be much simpler if all the hidden text boxes are inside a control array. Then you loop through each of them and look for a match. Isolate your search to within the Submit command button click event. A list box can be used to collect all the matched results.
-
Jul 29th, 2008, 03:27 AM
#7
Lively Member
Re: Searching Textboxes and Listboxes and dropdown lists
The following examples are using InStr (In String), which will go through the designated string and look for the provided data.
Syntax:
vb Code:
InStr(Start At Character, String One(your input data), String Two(what we're looking for), What type of comparison)
Searching in textbox:
vb Code:
If InStr(1, Text1.Text, Text2.Text, vbTextCompare) Then MsgBox("Found " & Text1.Text) Exit Function End If
Searching a listbox:
vb Code:
Function SearchTextString() Dim N As Long If Text1.Text = "" Then Exit Function For N = 0 To List1.ListCount - 1 If InStr(1, Text1.Text, List1.List(N), vbTextCompare) Then MsgBox("Found " & (N)) Exit Function End If Next N
Hope it helps =)
Please use the search function prior to posting a question and see if someone's already answered it.
-If I helped you, please rate me, as I'd do the same for you =)
-Remember to select the Resolved option for your post when you've gotten the answers you need.
-
Jul 29th, 2008, 07:38 AM
#8
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
Are the textboxes in another app though?
-
Jul 29th, 2008, 08:24 AM
#9
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
they are in the same app
@neato thanks for the start, it helps alot
-
Jul 29th, 2008, 08:25 AM
#10
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
Oh ok. Then go with neato. It's much easier that way.
-
Jul 29th, 2008, 08:37 AM
#11
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
i didnt really get what you said anyway lol
-
Jul 29th, 2008, 01:34 PM
#12
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
lol. Let's just say if the textboxes were in another app it would be a lot harder to read them.
-
Aug 1st, 2008, 02:45 AM
#13
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
thanks guys for all your help, just one more question, after i get them into a list, is it possible to make the results into links that take you to the textbox or listbox and highlight them? and if its a long list or paragrapgh, take you to that section of it... do you get what im saying?
-
Aug 1st, 2008, 07:45 AM
#14
Re: Searching Textboxes and Listboxes and dropdown lists
 Originally Posted by Neato
The following examples are using InStr (In String), which will go through the designated string and look for the provided data.
Syntax:
vb Code:
InStr(Start At Character, String One(your input data), String Two(what we're looking for), What type of comparison)
Searching in textbox:
vb Code:
If InStr(1, Text1.Text, Text2.Text, vbTextCompare) Then
MsgBox("Found " & Text1.Text)
Exit Function
End If
Searching a listbox:
vb Code:
Function SearchTextString()
Dim N As Long
If Text1.Text = "" Then Exit Function
For N = 0 To List1.ListCount - 1
If InStr(1, Text1.Text, List1.List(N), vbTextCompare) Then
MsgBox("Found " & (N))
Exit Function
End If
Next N
Hope it helps =)
Umm...Can this code be used in a datagrid?
Manny Pacquiao once posted in his twitter:
It doesn't matter if the grammar is wrong, what matter is that you get the message
-
Aug 1st, 2008, 08:19 AM
#15
Re: Searching Textboxes and Listboxes and dropdown lists
I don't know about a datagrid (never use them), but it could be easily modified for a Listview.
-
Aug 2nd, 2008, 04:52 PM
#16
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
ok, i finally got around to working on my app again and i got some questions
what should i put here
InStr(Start At Character, String One(your input data), String Two(what we're looking for), What type of comparison)
at first i thought it was what the user was searching for, but it wasnt...
i used this fuction without the above and no matter what, i always get a message box saying it found what i was searching for even tho it doesnt exist. my guess is its because of the lack of the syntax but maybe not
Code:
If InStr(1, Text1.Text, Text2.Text, vbTextCompare) Then
MsgBox("Found " & Text1.Text)
Exit Function
End If
-
Aug 5th, 2008, 07:20 AM
#17
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
try:
Code:
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
MsgBox("Found " & Text1.Text)
Exit Function
End If
-
Aug 5th, 2008, 10:49 AM
#18
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
ok, that works better, idk if this is the best way to do it, but im gonna have it search the boxs one at a time, if it finds it, add it to a invisible listbox and move it on to the next box by the way of a if inside a if and if it doesnt find it, move on anyway
so basically, like this
Code:
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
'add to listbox
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
MsgBox("Found " & Text1.Text)
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
'add to listbox
Else
End If
Else
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
'add to listbox
Else
End If
End If
and so on. is ther a better way?
-
Aug 5th, 2008, 10:54 AM
#19
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
Use a recursive sub. Put only one instance of the if instr(.... end if part in a sub, and from that sub call the sub if the text is found.
for example:
Code:
Private sub AddToBox
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
'add to listbox
addtobox
Else
If InStr(1, Text1.Text, Text2.Text, vbTextCompare)>0 Then
'add to listbox
Else
End If
End If
End sub
-
Aug 6th, 2008, 03:17 PM
#20
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
well, i just found out sumting that really sucks, when i tested the search i just had one word in there, but when i accually put a paragraph in and searched. it returned negative every time unless i copied and pasted the whole paragraph into the searchbox
-
Aug 6th, 2008, 03:24 PM
#21
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
weird...send me your code through pm i'll see what i can do.. it's hard to picture the problem
-
Aug 6th, 2008, 03:39 PM
#22
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
-
Aug 6th, 2008, 05:13 PM
#23
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
-
Aug 7th, 2008, 07:39 AM
#24
Fanatic Member
Re: Searching Textboxes and Listboxes and dropdown lists
I know. I had just left the office when I made that post. Most of my work is done from my office M-F 8-5. It's 8:30 now. I'll do my best to take a look at it by the end of the day.
-
Aug 7th, 2008, 08:12 AM
#25
Re: Searching Textboxes and Listboxes and dropdown lists
-
Aug 7th, 2008, 12:49 PM
#26
Thread Starter
Junior Member
Re: Searching Textboxes and Listboxes and dropdown lists
oops, guess i had the wrong section...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|