Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Look for text

Status
Not open for further replies.

Vec

IS-IT--Management
Jan 29, 2002
418
US
I need to look at a text file and see if a specific string that is in a combo box on my form exists.

Pseudo code:
When user drops the combo box choices:

Look at approved.txt (using the App.Path & "\approved.txt" method) to see if what is selected in the combo box exists anywhere in approved.txt

If it does Then
WebMain.Navigate2 Combo1.Text
Else
MsgBox "Not Found"
End If

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Univer
 
Sorry, I messed up. Let me explain it like this:

approved.txt will contain root domains like this:

msn.com
yahoo.com
google.com

Here is what I am trying to do, this is pseudo mixed with real code:

Look at the string in txtFilter.txt
Compare it too all entries in approved.txt
If you find any entry in approved.txt that matches any part of txtFilter.Text
Then
WebMain.Navigate2 Combo1.Text
Else
MsgBox "Not Approved"

In other words, if txtFilter.txt has this string:
it would go to:
WebMain.Navigate2 Combo1.Text because yahoo.com is in approved.txt

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Univer
 
foundFlag = False
open File
do untill EOF
read line
if line entry = textbox.text then foundflag = True
loop
close file

if you need help with the code, let me know, but this should do the trick.

Somtimes, the easy answer is the hardest to find. :)
 
Have no idea where to put what you are showing me. Can you elaborate?

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Univer
 
OK, are all you entries in approved.txt all on a single line. Ie:

yahoo.com
msn.com
blabla.net etc.?

Is your string gonna exist of more than just yahoo.com, for instance it looks like it might read
First thing first:

What rebecca was saying is that you should open the file, go through each line in the file, and compare that line to your string.

It is done like this:

Dim inp_String As String

Open App.Path & "\approved.txt" for input as #1
while while not EOF(1)
input #1, inp_String
If inp_String = txtFilter.Text then
"do whatever you do"
End If
wend
Close #1

Of course as I mentioned, if your txtFilter.text does not contain only yahoo.com, you will have to do a bit more advanc search.....

If you need the advance search going, let me know, it's actually pretty easy so just let me know if you need it and I'll post it

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Thx everyone, I am almost there:

The list will contain entries like this:
microsoft.com
No - No - /files/mypage.html

The thing I need this to do is look at approved.txt line by line and match each line to ANY part of the string in txtFilter.Text
In other words, if yahoo.com is one of approved.txt's lines, then let me psuedo what I mean:

Instead of:
If inp_String = txtFilter.Text Then

it needs to do:
If inp_String = any part at all of txtFilter.Text Then



So basically if txtFilter.Text contained any one of these:
or even

all of these would be = to txtFilter.Text because each contains yahoo.com
which is an entry in approved.txt


-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Univer
 
Check out the Instr() function which returns the start point of one string within another. You'll need to loop through your approved list.

Pseudo code

Do until end of list
If Instr(inputstring, approvedstring) > 0 then
'It's in the list
Loop


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top