[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Concatenate response.write statements

Hi Experts

We have the following code that outputs the correct information in the browser. What is the best way (with example please) to turn this into one complete variable.

Thanks for your time.
<%
While (NOT WA_eCart_EOF(GSDeCart))
	Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Quantity"))
	Response.Write("x&nbsp;")
	Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Description"))
Set GSDeCart = WA_eCart_MoveNext(GSDeCart)
	If NOT WA_eCart_EOF(GSDeCart) Then 
		Response.Write(",&nbsp;") 
	Else
		Response.Write(".")
	End If
Wend
%>

Open in new window

0
hnEE
Asked:
hnEE
  • 3
  • 2
1 Solution
 
szarangerCommented:
is this what you are trying to achive:

While (NOT WA_eCart_EOF(GSDeCart))
        Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " &   WA_eCart_DisplayInfo(GSDeCart, "Description")
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
small correction:
Dim next_character 
next_character = ""
While (NOT WA_eCart_EOF(GSDeCart))
   Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " &   WA_eCart_DisplayInfo(GSDeCart, "Description" & next_character)
   next_character = ","
Wend
Response.Write(".")

Open in new window

0
 
hnEEAuthor Commented:
Hi Experts

I may not have explained myself correctly.

The code in our example works correctly. It shows in the browsers exactly what it should. However, say it renders out "1x Dog, 2x Cat."

We would like to turn that output into a variable:

myVar = "1x Dog, 2x Cat."

I hope this make is clearer.

Thanks for your time
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, that is possible also:
Dim result
Dim next_character 
next_character = ""
While (NOT WA_eCart_EOF(GSDeCart))
   result = result & WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " &   WA_eCart_DisplayInfo(GSDeCart, "Description" & next_character)
   next_character = ","
Wend
Response.Write(result & ".")

Open in new window

0
 
hnEEAuthor Commented:
Hi angelIII

Your response was very close - but showed me the basic idea. This got us what we needed in the end. Does that look okay to you?

Thanks for your help
Dim result
Dim next_character 
next_character = ", "
While (NOT WA_eCart_EOF(GSDeCart))
   result = result & WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " &   WA_eCart_DisplayInfo(GSDeCart, "Description") & next_character
   If WA_eCart_EOF(GSDeCart) Then 
		next_character = ", " 
	Else
		next_character = "."
	End If
Set GSDeCart = WA_eCart_MoveNext(GSDeCart)
Wend
Set GSDeCart = WA_eCart_MoveFirst(GSDeCart)
Response.Write(result)

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
not wrong.
but not optimal :)

check out the stringbuilder class to reduce the string concatenation "overhead":
http://msdn.microsoft.com/en-us/library/ms972323.aspx

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now