|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with Instr to find a spaceI am trying to use Instr to find the model number of seveal different types of computers. I am getting and error at strC. Here is the code: 'Determine the model number of the PC Set CompSys = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48) For Each sysItem In CompSys fmfg = Trim(sysItem.Manufacturer) fmm = Trim(sysItem.Model) Wscript.Echo fmm arrComputers = Array("D420","D430","D620","D630", _ "E4300","E6400","745","755", _ "760","490","690", _ "M4300","M4400","M65","T3400", _ "T5400","T7400","dc7600","dc7700", _ "dc7800","T60","T61") For Each strA In arrComputers strB = Instr(1,fmm,strA) strC = Instr(strB,fmm,(CHr(32))) <---- Error is here strD = Mid(fmm,strB,strC) Wscript.Echo strD And here is the error: Microsoft VBScript runtime error: Invalid procedure call or argument: 'Instr' Any help would be appriciated. OldDog wrote on Wed, 17 Jun 2009 07:54:16 -0700 (PDT):
> Hi, If strB is zero then this won't work because the first value must be a > I am trying to use Instr to find the model number of seveal different > types of computers. I am getting and error at strC. > strC = Instr(strB,fmm,(CHr(32))) <---- Error is here number greater than zero. Try this: For Each strA In arrComputers strB = Instr(1,fmm,strA) If strB > 0 Then strC = Instr(strB,fmm,(CHr(32))) If strC > 0 Then strD = Mid(fmm,strB,strC) WScript.Echo strD End If End If Next Also note that InStr is case sensitive unless you provide the 4th parameter with the constant vbTextCompare, so you may need to amend your InStr calls if you need case-insenstive checks. -- Dan OldDog wrote:
> Hi, Is this client-side code? You should probably have posted it to> > I am trying to use Instr to find the model number of seveal different > types of computers. I am getting and error at strC. m.p.scripting.vbscript. > Echo?? Maybe you actually did mean to post this in> Here is the code: > > 'Determine the model number of the PC > Set CompSys = objWMIService.ExecQuery("Select * from > Win32_ComputerSystem",,48) > For Each sysItem In CompSys > fmfg = Trim(sysItem.Manufacturer) > fmm = Trim(sysItem.Model) > Wscript.Echo fmm m.p.scripting.vbscript ...? Show quoteHide quote > Well, it must be an invalid procedure call. Echo (or Response.Write if> arrComputers = Array("D420","D430","D620","D630", _ > "E4300","E6400","745","755", _ > "760","490","690", _ > "M4300","M4400","M65","T3400", _ > "T5400","T7400","dc7600","dc7700", _ > "dc7800","T60","T61") > For Each strA In arrComputers > strB = Instr(1,fmm,strA) > strC = Instr(strB,fmm,(CHr(32))) <---- Error is here > strD = Mid(fmm,strB,strC) > > Wscript.Echo strD > > And here is the error: > > Microsoft VBScript runtime error: Invalid procedure call or argument: > 'Instr' > > Any help would be appriciated. this is really an asp question) each argument value you are passing to see why. If this does not reveal the problem to you, show us one of the set of argument values that produces the error. -- HTH, Bob Barrows
Other interesting topics
How can I type in the combo box <select> ?
How to change all relative paths in a website??? What is the real IP address of the site visitor? ASP.NET and HTML Select INTO, UNION ASP 0126 Pinpoint unspecified error for objXMLHttp.send objXML statement Microsoft OLE DB Provider for ODBC Drivers error '80004005' ClientScript working in IE but not in Mozilla technology choice |
|||||||||||||||||||||||