Skip to main content
Bounty Awarded with 50 reputation awarded by msvuze
added 5 characters in body
Source Link
chue x
  • 18.9k
  • 8
  • 59
  • 71

Instead of for each, you need to use a numeric indexer intoto access the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x

Dim value

for x = 1 To Request.Querystring.Count
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

Instead of for each, you need to use a numeric indexer into the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x

Dim value

for x = 1 To Request.Querystring.Count
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

Instead of for each, you need to use a numeric indexer to access the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x

Dim value

for x = 1 To Request.Querystring.Count
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

deleted 8 characters in body
Source Link
chue x
  • 18.9k
  • 8
  • 59
  • 71

Instead of for each, you need to instead use a numeric indexer into the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x
 
Dim key
Dim value

for x = 1 To Request.Querystring.Count
    key = Request.Querystring.Key(x)
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

Instead of for each, you need to instead use a numeric indexer into the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x
 
Dim key
Dim value

for x = 1 To Request.Querystring.Count
    key = Request.Querystring.Key(x)
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

Instead of for each, you need to use a numeric indexer into the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x

Dim value

for x = 1 To Request.Querystring.Count
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX

Source Link
chue x
  • 18.9k
  • 8
  • 59
  • 71

Instead of for each, you need to instead use a numeric indexer into the collection. The latter preserves the order of the input string.

<%
Dim qstr
Dim count: count = 0
Dim x

Dim key
Dim value

for x = 1 To Request.Querystring.Count
    key = Request.Querystring.Key(x)
    value = Request.Querystring.Item(x)
    
    If value <> ",EMPTY" Then
        qstr = qstr & "&s" & count & "=" & value
        count = count + 1
    End If
Next

If qstr <> "" Then
    qstr = Right(qstr, Len(qstr) - 1)
End If

Response.Write "<p>Input:<br />" & Request.Querystring & "</p>"
Response.Write "<p>Output:<br />" & qstr & "</p>"
%>

Input:

s0=Columbus,OH&s1=,EMPTY&s2=,EMPTY&s3=Chicago,IL&s4=,EMPTY&s5=,EMPTY&s6=,EMPTY&s7=,EMPTY&s8=Akron,OH&s9=,EMPTY&s10=,EMPTY&s11=Plainfield,IN&s12=,EMPTY&s13=Miami,FL&s14=,EMPTY&s15=,EMPTY&s16=,EMPTY&s17=,EMPTY&s18=,EMPTY&s19=,EMPTY&s20=,EMPTY&s21=Memphis,TN&s22=Denver,CO&s23=Dallas,TX

Output:

s0=Columbus,OH&s1=Chicago,IL&s2=Akron,OH&s3=Plainfield,IN&s4=Miami,FL&s5=Memphis,TN&s6=Denver,CO&s7=Dallas,TX