Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2004, 11:14 AM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default session variable content count

hi

i have the following session variable defined :

Session("MemberId")

this contains a list of comma delimited Member_id's ..e.g

1,2,3,4,5,6,7

i want to count how many Id's there are. I was hoping this could be acheived with something like.

Session("MemberId").count or Session("MemberId").contents.count

but it doesn`t work. Do i have to write a function to recurse through each item and count ?

thanks

dave

 
Old October 23rd, 2004, 07:28 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Split the string on the commer, then get the ubound of the array:

   dim myArray,totalLen
   MyArray = Split(Session("MemberId"), ",", -1, 1)
   totalLen = ubound(myArray)
   response.write totalLen

If you build the session var in a loop, incriment a counter as the string is created would be another way. Unless of course you intend to split the array anyway therefore the above method would be the one.

NOTE: The array starts at 0 so the result is 6 even though there are seven elements

Wind is your friend
Matt
 
Old October 24th, 2004, 08:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

In addition to that, add it by one always to get the correct result, which is indirectly said in Matt's post;).
Code:
response.write totalLen + 1
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 24th, 2004, 11:43 AM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

cheers guys






Similar Threads
Thread Thread Starter Forum Replies Last Post
session and variable... badboy1 ASP.NET 3.5 Basics 1 August 3rd, 2008 09:14 AM
Setting xsl:variable maximum count isme XSLT 2 March 14th, 2006 03:39 AM
constructing node-set content to xsl:variable MrWay XSLT 3 February 28th, 2006 10:39 AM
Session Variable youyou_hym Dreamweaver (all versions) 4 January 20th, 2005 11:48 AM
How count session connected to web ? glezmart ASP.NET 1.0 and 1.1 Professional 12 January 16th, 2004 04:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.