Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting an Array of Strings Problem 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello I am having trouble using an array of information. I am storing the following type data in a Sesion variable on page1.asp:

Session("GridFields")="A, B, C, D"

On page2.asp I need to extract these in a for-loop but the problem I have discovered is that they are not each within quotes.

As a test, this works on page2.asp (recreating the values):
Dim aFields
aFields = array("A", "B", "C", "D")

This DOES NOT work (grabbing the data from the session var:
Dim aFields
aFields = Split(Session("GridFields"), ",")

I tried various cocantenation methods but do not quite have it (bad idea maybe too). FYI here is where it blows up - each field must be in quotes to work:

<% for z = 0 to UBound(aFields) %>
<% sCurrFieldName = aFields(z) %>
<% sCurrFieldValue = oRS(sCurrFieldName) %>
<% if sCurrFieldValue = &quot;&quot; then %>
<td>&nbsp</td>
<% else %>
<td><%=sCurrFieldValue%></td>
<% end if %>
<% next %>

Tough one (for me).

What can you recommend guys!

Michael
 
try:

sCurrFieldValue = oRS(&quot;&quot; & sCurrFieldName & &quot;&quot;)
 
i also noticed you need to get the spaces out of the field name:

<% sCurrFieldName = Trim(aFields(z)) %>
<% sCurrFieldValue = oRS(&quot;&quot; & sCurrFieldName & &quot;&quot;) %>
 
THIS IS WONDERFUL!!!!

Lobstah , between your two suggestions this has fixed it! Wow, many hours on this one. Tek-tips is worth it's weight in gold.

Thanks again,

Michael

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top