Print Page | Close Window

Spliting a string

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10486
Printed Date: 31 March 2026 at 5:49pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Spliting a string
Posted By: zaboss
Subject: Spliting a string
Date 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/>



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: Mart
Date 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


Posted By: zaboss
Date Posted: 17 May 2004 at 3:35pm

Nope, had tryed that and it throws me an error:

 Subscript out of range: '[number: 1]' < =text/>



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: dpyers
Date 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...

Quote "<a href="detalii_vizita_doctori.asp?fname=<%= nume(0) " %>&lname=<%= nume(1) %>"><%=RS( "strDoctor")%>



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mart
Date Posted: 17 May 2004 at 3:56pm
Oh, in .net it is length... When you say it's not splitting what do you mean? 


Posted By: zaboss
Date 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/>



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: dpyers
Date 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.


Posted By: zaboss
Date 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.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net