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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mid doesn't work?

Status
Not open for further replies.

JavaDude32

Programmer
Aug 25, 2001
180
US
I'm not sure if this is the correct board, but as this code is in an ASP page and the default language is vbscript I'll post here. I have the following code:

Dim intTemp
For I = 0 to Len(Session("mapFeatures"))-1 Step 1
intTemp = Session("mapFeatures")
intTemp = Mid(intTemp,I)'Why isn't MID working??
intTemp = CInt(intTemp)
mapFeatures(intTemp) = "yes"
Next

The Error thrown is:

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

I thought Mid was a built in function for vbscript (which ASP shouldn't affect that way)? Has anyone ever come across this problem?

BTW
CInt, Len and such works
 
MID (string, first_char, num_chars)

is the syntax for the function - u had missed an argument.
 
Ah, thank you. Also noticed now after its been awhile that the second is being intepretted as a character and not a number.
 
Yeah to a degree, I would have grabbed the rest of the string had you not pointed that out, yet I now face the problem of getting the Mid Function to take the second argument as a variable as that is throwing the error. It needs to be in Long format and even CLng isn't working to do this.
 
Mid(intTemp,I)

Is not right like that. You need a third parameter, the length of the character string. Plus "I" can not equal zero or below zero. You might want to check if "Session("mapFeatures"))-1" is at least 1 or bigger than that before you run Mid.

A tricky way of making intTemp variant to a number is:

intTemp = intTemp * 1

:)
 
The length argument of the MID function can be = 0 buut not < 0.
Try this.
Dim s As String
s = &quot;A&quot;
s = Mid(s, 1, 0)
MsgBox &quot;'&quot; & s & &quot;'&quot;

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top