Is there any efficient and easy way to find a certain string in a file besides....
Dim asdf$
Open file For Input As #1
Do Until EOF(1)
Line Input #1, asdf
If asdf = "string" Then Goto Lol
Loop
Lol:
Close #1
which is what i have been using for all the while?
Yes, you can use Regular Expressions. Take a look at http://visualbasic.about.com/od/usingvbnet/l/blregexa.htm (http://visualbasic.about.com/od/usingvbnet/l/blregexa.htm) for a brief stint in their use in VB6 as well as http://www.regular-expressions.info/vb.html (http://www.regular-expressions.info/vb.html) which as a site is a great reference for regex.
Regular expressions are also supported by the Microsoft .NET Platform and are consequently available in Visual Basic .NET.
Or load the entire file using binary access read, and then use instr.
Myndfyre, thanks for helping. RegExs look very interesting and i might use that... but it would still require me to open the file as binary in order to use it. and that's basically what reality said......
Quote from: [RealityRipple] on March 20, 2007, 07:25 PM
Or load the entire file using binary access read, and then use instr.
because somewhere in that article it goes on to state how InStr() and Like() (like is good, but it's only for ranges of ascii characters) are the only two native VB6 regex functions. SO my best bet is to do what reality said, open it in binary and use InStr() until i find more documentation about and gain deeper knowledge of regexes.
Well, there is one ity bity problem with that method. Depending on the file you load, it will take more time, ram, and process usage.
Quote from: brew on March 20, 2007, 08:08 PM
Myndfyre, thanks for helping. RegExs look very interesting and i might use that... but it would still require me to open the file as binary in order to use it. and that's basically what reality said......
Quote from: [RealityRipple] on March 20, 2007, 07:25 PM
Or load the entire file using binary access read, and then use instr.
because somewhere in that article it goes on to state how InStr() and Like() (like is good, but it's only for ranges of ascii characters) are the only two native VB6 regex functions. SO my best bet is to do what reality said, open it in binary and use InStr() until i find more documentation about and gain deeper knowledge of regexes.
Note that Like isn't a function, it's an operator
Its a crazy one! Infact, too crazy to be considered an operator! heh... it should be a function though.