Solved VBS: How to make instr Ignore case?

Microsoft Windows xp professional w/ sp2
January 5, 2010 at 16:31:19
Specs: Windows XP, lol
I'm using a vb script - here's my script:

const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile1 = objFSO.OpenTextFile("whitelist", ForReading)

strCurrentDevices = objFile1.ReadAll

Set objFile2 = objFSO.OpenTextFile("ntbtlog.txt", ForReading)

Do Until objFile2.AtEndOfStream
strAddress = objFile2.ReadLine
If InStr(strCurrentDevices, strAddress) = 0 Then
strNotCurrent = strNotCurrent & strAddress & vbCrLf
End If


Wscript.Echo "Entries which are not on the whitelist will appear in output.txt"

Set objFile3 = objFSO.CreateTextFile("output.txt")

objFile3.WriteLine strNotCurrent

How do I make the "instr" comparison ignore case-sensetivity?


See More: VBS: How to make instr Ignore case?

Report •

January 5, 2010 at 17:09:48
strCurrentDevices = ucase(objFile1.ReadAll)

If InStr(strCurrentDevices, ucase(strAddress)) = 0 Then

or "lcase()", as long as they're both the same.
you could put them on one line, but then you are repeating the ucase conversion of "strcurrentdevices" hundreds of times.

Report •

January 5, 2010 at 17:25:07
✔ Best Answer
you can do case insensitive using Instr's vbTextCompare,

If InStr(1,strLine,"word",1) > 0 Then
		WScript.Echo "Found"
End If 

GNU win32 packages | Gawk

Report •
Related Solutions

Ask Question