ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 7th, 2003, 01:39 PM
whitecomet whitecomet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Irvine, CA
Posts: 3 whitecomet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
removing empty elements

Hi Guys,
I have this form that collects text values and I use VBCrLf as delimiters to tell one element from another. Sometimes, I get several empty elements. Is there a way to remove those elements?

Thanks in advance

Reply With Quote
  #2  
Old August 7th, 2003, 02:11 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I don't get it

You have a <form>...</form> with <textboxes> right?

Then what?

The user submit's your <form>...</form> and you try to retrieve the values from your <form>...</form> ?

Is that it?

Vlince

Reply With Quote
  #3  
Old August 7th, 2003, 03:39 PM
whitecomet whitecomet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Irvine, CA
Posts: 3 whitecomet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have an ASP processing file that takes the values in the textfield and make it into an array, based on VbCrLf(carriage return) as delimiters. I am wondering if someone enter an empty line, how do you remove it?? (I inserted some extra lines (empty), how do you remove it??)





I know for perl, you just Chomp the array, but what about for vbscript??

Reply With Quote
  #4  
Old August 7th, 2003, 03:43 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
While you're taking/retrieving the data from your <textfield> make/use the Trim() function so:

<%
Dim strTextBox1
Dim strTextBox2

strTextBox1 = Trim(Request.Form("txt1"))
strTextBox2 = Trim(Request.Form("txt2"))
%>

Hope this makes sense!
Sincerely

Vlince

Reply With Quote
  #5  
Old August 7th, 2003, 03:50 PM
whitecomet whitecomet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Irvine, CA
Posts: 3 whitecomet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi Vince, thanks so much for your help.

But that's not the problem I have.

my input is not a textbox, but a textfield consisting of many newlines.

so the variable will look like

txt1 VBCrLf txt2 VbCrLf txt3 VbcrLf.....etc

and I do use Trim to remove spaces.

and here are the problems
someone may put in things as such below:

VbCrLf VbcrLf Vbcrlf txt1 VbcrLF txt2 VbCrLf VbCrLf VbCrLf

so when I split on VbCrLf... I get array size of 7 when I should've just gotten an array size of 2...
Hope that explains my situation.

Reply With Quote
  #6  
Old August 7th, 2003, 03:57 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Ok so try replacing the VbCrLf with a space -->" "<--

then use the Replace() function and the Trim() once again

you say you have this:
VbCrLf VbcrLf Vbcrlf txt1 VbcrLF txt2 VbCrLf VbCrLf VbCrLf

Once the replace is done, you'll have this:
" " " " " " txt1 " " txt2 " " " " " "

Well the double quotes won't be there of course, its simply so that we can see that the Replace will replace the VbCrLf with a space --> " " <--

then you Trim() that so you end up having:
txt1 " " txt2

then you Split() on " "

So :

Response.Write Split(..., " ")(0) 'Should give you txt1
and
Response.Write Split(..., " ")(1) 'Should give you txt2

Hope this helps!
Sincerely

Vlince

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > removing empty elements


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway