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

Pulling Strings Apart

Status
Not open for further replies.

joeyh

Programmer
Nov 13, 2000
12
0
0
US
I need to know how to pull strings apart using asp. I come from a Visual Basic background but when I use the Visual Basic way, I get an error. Here is the script I am using:

Function Seperate(Field)
Field = Cstr(Field)
WhereSpace = InStr(Field, " ")
Field = Left(Field, WhereSpace - 1)
Seperate = Cnum(Field)
End Function

The error tells me that LEFT is an invalid procedure call or argument. I might just be over looking something but I would appreciate the help.
Thanks
 
Left is a valid VBScript function. I would check that the language that the ASP page is using is VBScript and not JScript as someone may have changed the default language setting.
The problem also might be that you are trying to returna a negative number of characters and that could be where the error lies.

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
I think James is right. Try doing it like this:

Function Seperate(Field)
Field = Cstr(Field)
WhereSpace = InStr(Field, " ")
if WhereSpace > 0 then
Field = Left(Field, WhereSpace - 1)
Separate = Cnum(Field)
else
Separate = 0
end if
End Function








nick bulka

 
If you want to break strings apart based on a particular character, you can use the split function.


nick bulka

 
Nick,

I am not very familiar with the split function. Can you give me an example.

Thanks,
Joey Harvey
 
Here's the format:

split(String Expression[, delimiter[, count[, compare]]])

In your case, you'd only have to do this (since " " is the default for delimiter):
myArray = split(Field)



Choo Khor
choo.khor@intelebill.com
 
I have gotten past the Left mismatch, but is now giving me an error:
Type Mismatch Cnum

Can anyone help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top