Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old March 23rd, 2004, 12:12 PM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default redim array specifically

Hi,

I have 24 checkboxes all with the same naming convention, each box has a value ranging from 1 to 23, what I need to do is fill in the gaps with a 0 value where the user doesn't select a value.

So lets say that the user selects:

1,2,3,4,5,6,7,15,18,19,20

what I want to do is use the split function on the next page to convert into an array but then I want to redim the array and fill in the missing values, so I would end up with:

1,2,3,4,5,6,7,0,0,0,0,0,0,0,15,0,0,18,19,20,0,0,0


is it possible to do this and if so how

Thanks for any help
Peter


  #2 (permalink)  
Old March 23rd, 2004, 04:14 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Isn't 1 to 23 = 23? Do you mean 0 to 23?

My suggestion would be to do something like this (my VBScript might be a little rusty)...

Dim arySelected
Dim aryPossible(23)
Dim i

arySelected = Split(Request.Form("checkboxes"), ",")

'Create all the zeros for all possibilities
For i = 0 To UBound(aryPossible)
   aryPossible(i) = 0
Next
'Go thru all the selected ones and fill in their
'respective elements in the "possible" array
For i = 0 To UBound(arySelected)
   aryPossible(arySelected(i)) = arySelected(i)
Next

Peter
------------------------------------------------------
Work smarter, not harder.
  #3 (permalink)  
Old March 24th, 2004, 09:44 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter that was exactly what I was looking for thank you, on another note, when I am looping through the array I am getting the correct results but I am losing the leading zeros, the section in question is:

If LastHour <> 0 Then
   TimeQuery = TimeQuery & "(time>" & LastHour & " & "
End If

The LastHour containing the array, so 02 become 2, I have tied to find a fumction that will maintain the zero but to no avail, any ideas on how to get around it, this is using VBscript

Many thanks again
Peter

  #4 (permalink)  
Old March 24th, 2004, 01:17 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You'll have to pad the integer yourself.

If LastHour < 10 Then
   LastHour = "0" & LastHour
End If


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Looping controls and array redim mega Excel VBA 2 April 19th, 2005 11:57 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Redim in c# quetzalcoatl C# 2 December 1st, 2003 12:26 PM





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