OldDog schrieb:
Quote:
> Hi,
>
> I 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
As Instr() returns a (numerical) Position, all your
variable names are guilty of type prefix fraud.
Quote:
> strB = Instr(1,fmm,strA)
strB (horror) will hold 0 (zero), if strA isn't found
Quote:
> strC = Instr(strB,fmm,(CHr(32))) <---- Error is here
you can't call Instr() with a (numerical) starting position
of 0.
----
Quote:
Quote:
>> nPos = Instr( 0, "x", "y" )
>>
Error Number: 5
Error Description: Ungültiger Prozeduraufruf oder ungültiges Argument
(invalid procedure call or invalid argument)
----
You need something like:
For Each strA In arrComputers
nStart = Instr( 1, fmm, strA )
If 0 < nStart Then
nEnd = Instr( nStart, fmm, " " )
If 0 < nEnd Then
' cut
Else
' surprise
End If
Else
' try next
End If
Next
Quote:
> 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.
>
>