Fix for VBScript Error: Invalid procedure call or argument: ‘Mid’

After long long time i have touched VBScript and was trying to traverse string character by character. I came across some weird error or may be i have not read VBScript for long long time.

When you try to traverse string character by character, never start with index 0 otherwise you will get the above error

Invalid procedure call or argument: ‘Mid’

Along with this you will get argument 2 is invalid or something like that.

To traverse string character by character in VBScript use the following snippet of code:

/**

inputString = “String traversal in VBScript”;
stringLength = len(inputString)

For i = 1 To stringLength
mychar = Mid(inputString, i, 1 )
WScript.Echo “My character is “+mychar
Next

*/

This is one of the way to traverse string in VBScript.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)