Hi
Can anybody please give me an example of howto search for a keyword in a textstring? The keyword is read in to the program as an commandline parameter.
If InStr(1, Command$, "Lookfor" Then MsgBox "Are you looking for me Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
Thanks Sunaj, that works but when i try to exchange "If InStr(1, Command$, "Lookfor"" with "If InStr(1, Command$, args)" where args is "Set args = WScript.Arguments" taken from the commandline i get an error.
Any idea why?
Hi Agian,
You haven't included object creation and explicit declaretion for WScript - which I'm not sure what is. I would recommend you to use explict declarations for all you variables.
But what about:
-----------------------------------
Sub main
Dim f As Byte, a() As String
f = FreeFile
Open "c:\myfile.txt" For Input As #f
a = Split(Input(LOF(f), #f), vbCrLf)
Close #f
f = FreeFile
Open "c:\myfile.txt" For Output As #f
For i = 0 To UBound(a)
If InStr(1, a(i), Command$) = 0 Then Print #f, a(0)
Next i
Close #f
end sub
-----------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.