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

Posts: 317
Name: This Space for Rent
Location: Georgia
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?
__________________
Daniel
"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
When You Register, These Ads Go Away!
Old 12-04-2006, 12:30 PM Re: Help with split()
Average Talker

Posts: 22
Name: Ophir
Location: Israel
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 Visit ophir.oren's homepage!
 
Old 12-06-2006, 02:20 PM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Yeah, that's what I mean. Thanx I'll give it a try.
__________________
Daniel
"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, 02:47 PM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
You may have better luck with split (your_string, vbCrLf) . I usually find it catches more line breaks that way.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-07-2006, 10:07 AM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
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
__________________
Daniel
"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, 10:57 AM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
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.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-07-2006, 12:49 PM Re: Help with split()
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
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!
__________________
Daniel
"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, 10:51 PM Re: Help with split()
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
No probs, dude. Good luck to you!
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

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

vB 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.15751 seconds with 12 queries