| Author |
Topic Search Topic Options
|
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Topic: Spliting a string Posted: 17 May 2004 at 3:19pm |
I have some problems spliting a string. I have a recordset thet contains First Name and Last Name of a person (Like Mancuso Jack). What I need is to split it in first name and last name an put it in a querystring like in maypage.asp?fname=Mancuso&lname=Jack.
I have tryed:
<% nume = Split(rs("strDoctor"), " ", -1) %> <td width="17%">Name of the Doctor</td> <td width="83%"><a href="detalii_vizita_doctori.asp?fname=<% = ""& nume(0) &"" %>&lname=<% = ""& nume(1) &"" %>"><%=RS("strDoctor")%></a></td> </tr>
|
, but is not spliting it. What am I doing wrong?
< =text/>
|
|
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 3:26pm |
|
Change
nume = Split(rs("strDoctor"), " ", -1)
to
nume = Split(rs("strDoctor"), " ")
Reason: The third parameter is length, if you set it to -1 it won't split the string
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 3:35pm |
Nope, had tryed that and it throws me an error:
Subscript out of range: '[number: 1]'
< =text/>
|
|
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 3:53pm |
Your split looks ok. Might be in the format of the href. You're not doing a response.write there, so you can replace the double "" with ".
The -1 just indicates to split the entire string.
As a matter of fact, just get rid of the double quotes entirely.
EDIT, the href should look like this...
"<a href="detalii_vizita_doctori.asp?fname=<%= nume(0) " %>&lname=<%= nume(1) %>"><%=RS( "strDoctor")%> |
Edited by dpyers
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 3:56pm |
|
Oh, in .net it is length... When you say it's not splitting what do you mean?
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 4:00pm |
Instead of spliting Mancuso Jack in "Mancuso" and "Jack" it does nothing at all. It still remains Mancuso Jack.
< =text/>
|
|
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 17 May 2004 at 4:08pm |
This statement works for me in something I did last night. arrServiceName = split(strServiceNames," ", -1)
The only two things I could suggest now would be to check that the white space between the names is really a space and to try setting a string to rs("strDoctor") and then splitting the string.
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 18 May 2004 at 11:43am |
|
Well, the code was OK. It was the records in the dbs that were wrong. Although it was indeed "Mancuso Jack", with a space within, actually for some reasons it wasn't read as a space but who know what. Now it works OK.
|
|
|
 |