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

Mid not working?

Status
Not open for further replies.

ironhide1975

Programmer
Feb 25, 2003
451
US
Hey trying to do a simple mid

Code:
DividerPos =  Instr(1, FirstName, " ", 1)
Last =        mid(First,DividerPos,50)

and I get this error

Code:
Microsoft VBScript runtime error '800a0005' 

Invalid procedure call or argument: 'mid'

 
I think you are putting the wrong parameters in the Mid function

It needs to be Mid(string, int, int), I believe that the variable First is not a string variable, I tested this and got the same error you did when First was not a string.

[monkey][snake] <.
 
First is the string variable, I basically want to find the space in the string and break it apart because its a first and last name.

 
[tt]DividerPos = Instr(1, FirstName, " ", 1)
Last = mid(First[red]Name[/red],DividerPos[red]+1[/red],[blue]len(FirstName)-DividerPos[/blue])
[/tt]
That number is the exact value. The freedom is that it can be larger but not smaller. If no space appears, the whole string is returned. If multiple space, its return the substring after the first.
 
figured it out, sometimes the DividerPos would be 0 and thus produce an error. Sorry for the inconvenience.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top