|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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?? |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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. |
|
#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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > removing empty elements |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|