Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Spliting a string
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Spliting a string

 Post Reply Post Reply
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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/>

Cristian Banu
Soft 4 web
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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")%>



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2004 at 3:56pm
Oh, in .net it is length... When you say it's not splitting what do you mean? 
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.