Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 12-01-2006, 05:33 PM Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
Maybe it's split...
I want to be able to take data from a textbox containing carriage returns to split the records into an array so that I can add each line as a new record in a database. I want to try to avoid delimiting it by spaces, comma, and any other special character. I know that the data will be consistent with a line return.

Anyone have an idea?
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
 
Register now for full access!
Old 12-04-2006, 01:30 PM Re: Help with split()
Average Talker

Posts: 22
Name: Momo
Trades: 0
you mean splitting a text and use line break as the delimiter?

if so, I'm not sure because I haven't tried it but how about =split(yourstring,chr(13))
ophir.oren is offline
Reply With Quote
View Public Profile
 
Old 12-06-2006, 03:20 PM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
Yeah, that's what I mean. Thanx I'll give it a try.
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Old 12-06-2006, 03:47 PM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You may have better luck with split (your_string, vbCrLf) . I usually find it catches more line breaks that way.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-07-2006, 11:07 AM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
Thanks Adam. That's actually what I ended up with. I replaced it with a comma and then split it as I thought this would be safer...?

Code:
txt = replace(request.form("multiNum"), vbcrlf, ",")
txtSplit=Split(txt, ",")
For i = LBound(txtSplit) TO UBound(txtSplit)
   'call function to insert records into database.
Next
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Old 12-07-2006, 11:57 AM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Two things on that piece of code, Dan:

1) Your lower bound on a split array is always 0. So LBound (txtSplit) can be safely replaced with 0, and your script will perform somewhat faster (since no call to an ASP function is necessary.)

2) As far as your comma idea goes, I'm going to do something silly to illustrate a point. The reason I'm doing something silly is because your users will too.

Hello, my name is Adam.
I like cars, boats, and planes.

If you use the comma character as your split point, you'll end up with something like this:

Hello
my name is Adam.
I like cars
boats
and planes.

Which is probably what you don't want.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-07-2006, 01:49 PM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
Good point and I probably wouldn't do something like this for a large scale app, but it's actually a very small web app for work and there is really only one way we will enter data. We generally have a list of numbers that are dynamic and other fields are pretty much static. So, to help increase efficiency, we can take just the list of numbers and have the server populate the other (relatively) static fields. I can also do some validation, but I don't think it'll be necessary.

Great catch and thanks again Adam!
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Old 12-07-2006, 11:51 PM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
No probs, dude. Good luck to you!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Help with split()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.98488 seconds with 12 queries