Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mid( ) function, Invalid argument????

Status
Not open for further replies.

rudejohn

IS-IT--Management
Jul 11, 2003
130
US
Here's my problem:

I'm calling a Mid() function, here's my code:
temp1 = Mid(Rs("dt2"),11,2)

Where Rs("dt2") is a date coming from a database (through a ResultSet). This code executes CORRECTLY.

Now, I don't want 11 as my second parameter. I want a VARIABLE because the position within the string changes. If I replace the 11 with "firstColon," an Integer which is always in the correct range, I get the following error:

Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'Mid'

I've replaced the 11 with a variable which is ALWAYS between 11-13. If I leave a hard-coded number in, it works fine. Here's the REAL kicker: If I put an assignment statement for firstColon above it, such as "firstColon = 12", it STILL works fine. It's just when firstColon is a variable that it doesn't work. But I'm having it print ALL instances of firstColon with a Response.Write, and they're ALL correct and within range. Any help????
 
Okay, I answered my own question by putting in some fierce error-handling. Thanks to those who at least read this.
 
Any chance you could post what your solution was? I'm having the same problem and would be interested in finding out how you solved your issue.

Thanks.
 
Invalid procedure call or argument has to have correct parameters; nonzero, positive integers.

Actually, my problem was that I had a number that was not an Integer that was *sometimes* getting into the equation. Ensure that you've rounded all your inputs, and that none of them can EVER be zero or negative (I put in a clause beforehand that if any of them were <= zero, it assigned a default value).

Hope this helps a bit...

RJ

************
RudeJohn
************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top