Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:26:30+00:00 2026-06-17T08:26:30+00:00

This is my first post here but reading other posts has helped me with

  • 0

This is my first post here but reading other posts has helped me with countless issues. You guys are awesome. So thanks for all the help you guys have provided up to this point and thanks in advance for any advice you can give me here.

So, I’m working on this script that will end up randomly choosing numbers from a list in an array. What I’m trying to do in this section is read the number in each element of the third dimension of NumberHistoryArray and write the corresponding number from the second dimension the number of times indicated in the third into the numberDump array. I also have it writing to a text file just to see that it works and to have something to reference if I run into other problems and need to know what the output is.

Edit
The second dimension of NumberHistoryArray contains the numbers 1 through 35. The third dimension contains the number of times each of the numbers in the second dimension should be repeated when written to the numberDump array.

If NumberHistoryArray(4, 0, 0) is 4, for example, it should write the number 1 four times, once each in numberDump(0, 0, 0) through (0, 0, 3) and dynamically resize numberDump() as needed to fit each 1. The result of echoing numberDump(0, 0, 0) through numberDump(0, 0, 3) should be 1 1 1 1. If NumberHistoryArray(4, 1, 1) is 7, it should write the number 2 seven times in numberDump(1, 1, 0).
Edit

When writing to the numberDump text file from within the Do loop, the text file is perfect. If I echo the contents of each element in the array from inside the Do loop, the contents are accurate. Once outside the Do loop, the contents are blank. Any takers?

Dim NumberHistoryArray(5, 34, 3)
Dim numberDump()
reDim numberDump(3, 34, 0)

' generate the number list and store it in the array
For n = LBound(numberDump, 1) to UBound(numberDump, 1)
  i = 1
  x = 0
  y = 1

  Do
    Set objTextFile = objFSO.OpenTextFile("numberDump.txt", 8, True)

    ' determine how many elements are needed in the third dimension of the
    ' array to store the output
    x = x + NumberHistoryArray(4, i - 1, n)

    ' resize the array
    ReDim Preserve numberDump(3, 34, x)

    ' input the numbers
    For z = y to UBound(NumberDump, 3)
      numberDump(n, i - 1, z) = i
      objTextFile.WriteLine(numberDump(n, i - 1, z))
    Next

    objTextFile.Close

    y = x + 1
    i = i + 1
  Loop Until i = 36
Next

For i = 0 to UBound(numberDump, 2)
For j = 0 to UBound(numberDump, 3)
    wscript.Echo numberDump(0, i, j)
Next
Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:26:31+00:00Added an answer on June 17, 2026 at 8:26 am

    The issue here is that you are resizing the third dimension of numberDump to x each iteration, and you are resetting the value of x with each iteration of n. For example, when n is 0, by the end of the Do loop, x may be equal to 10. However, on the next iteration, when n is 1, x is reset to 0 and you end up resizing the third dimension of numberDump to 0, erasing most of the existing elements.

    There are two methods of working around this:

    1. Keep track of the maximum value of x for all iterations of n. Use that value to resize numberDump as necessary.

    2. Use a jagged array (aka, an array of arrays). In this case, numberDump would be a two-dimensional array whose values are arrays containing the repeated values. This would allow each value to have a different length, as opposed to a three-dimensional array, where the third dimension always has the same length.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post here. I have been reading posts here since I
This is my first post, but I've been reading here for ages taking in
This is my first post here - but I've been a reader for a
First post here but been here 1000 times, really like the contribution from other
This is my first post here, but I've using this site regularly to help
This is my first post here so go easy. I am trying to build
This is my first post here. I have a problem. I need to take
this is my first post here on stackoverflow and am very impressed by the
My first post here, so i hope this is the right area. I am
um, first post here, this place seems to be all over google and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.