Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Assigning values in an array...

Assigning values in an array...

Scheduled Pinned Locked Moved Database
data-structuresbusinessregextutorialannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    new_phoenix 0
    wrote on last edited by
    #1

    I need some assistance with a small application. I need to loop through an existing array and to assign a value to it in a pattern. I thought that I could do it, but I am really at a loss as to how to proceed. I tried a wide variety of approaches but it does not yield the correct results. As a smaller scale version of the array. Let us say that the array consists of 392 elements. The first element of the array consists of date values from 12/30/2007 and it proceeds up until 1/24/2009. The second element should be number values from 1 to 13. The pattern is that there should be 28 values with the value 1, and then 28 values with the value 2, and then 28 values with the value of 3. This procedure continues with 28 values of the value 13. After the 28th value of 13, the numbering system should start over again with 28 values with the value of 1. This should populate all of the elements of the 392 element array. The code below that I have written, for some reason, does not include the 28th value for each of these assignments. Also, it includes a 14th value following the last 13 value assignment. Please provide me with some assistance! :confused::confused::confused:

    Public Function ZodiacPeriod(dteInputDate)
    Dim dteStart As Date
    Dim dteEnd As Date
    Dim intDateCount As Integer
    Dim intRow As Integer
    Dim intX As Integer
    Dim intCounter As Integer
    Dim arrArray(392, 1)

    intX = 1
    dteStart = #12/30/2007#
    dteEnd = #1/24/2009#
    intDateCount = DateDiff("d", dteStart, dteEnd)
    
    'Loading the array with dates
    For intRow = 1 To intDateCount
        arrArray(intRow, intColumn) = dteStart
        dteStart = dteStart + 1
    Next
    
    'The second element value is assigned here
    For intRow = 0 To 392
        If intCounter <= 27 Then
            If intX >= 14 Then
                intX = 1
            End If
            intCounter = intCounter + 1
        Else
            intCounter = 1
            If intX < 14 Then
                intX = intX + 1
            End If
        End If
        arrArray(intRow, 1) = intX
    Next intRow
    
    'Now to go through the array and return the value in the array
    For intRow = 0 To 392
        If arrArray(intRow, 0) = dteInputDate Then
            ZodiacPeriod = arrArray(intRow, 1)
            Exit For
        End If
    Next intRow
    

    End Function

    I have encountered problems in which a value of 14 is assigned. I have encountered problems in which the requirements are not ma

    R 1 Reply Last reply
    0
    • N new_phoenix 0

      I need some assistance with a small application. I need to loop through an existing array and to assign a value to it in a pattern. I thought that I could do it, but I am really at a loss as to how to proceed. I tried a wide variety of approaches but it does not yield the correct results. As a smaller scale version of the array. Let us say that the array consists of 392 elements. The first element of the array consists of date values from 12/30/2007 and it proceeds up until 1/24/2009. The second element should be number values from 1 to 13. The pattern is that there should be 28 values with the value 1, and then 28 values with the value 2, and then 28 values with the value of 3. This procedure continues with 28 values of the value 13. After the 28th value of 13, the numbering system should start over again with 28 values with the value of 1. This should populate all of the elements of the 392 element array. The code below that I have written, for some reason, does not include the 28th value for each of these assignments. Also, it includes a 14th value following the last 13 value assignment. Please provide me with some assistance! :confused::confused::confused:

      Public Function ZodiacPeriod(dteInputDate)
      Dim dteStart As Date
      Dim dteEnd As Date
      Dim intDateCount As Integer
      Dim intRow As Integer
      Dim intX As Integer
      Dim intCounter As Integer
      Dim arrArray(392, 1)

      intX = 1
      dteStart = #12/30/2007#
      dteEnd = #1/24/2009#
      intDateCount = DateDiff("d", dteStart, dteEnd)
      
      'Loading the array with dates
      For intRow = 1 To intDateCount
          arrArray(intRow, intColumn) = dteStart
          dteStart = dteStart + 1
      Next
      
      'The second element value is assigned here
      For intRow = 0 To 392
          If intCounter <= 27 Then
              If intX >= 14 Then
                  intX = 1
              End If
              intCounter = intCounter + 1
          Else
              intCounter = 1
              If intX < 14 Then
                  intX = intX + 1
              End If
          End If
          arrArray(intRow, 1) = intX
      Next intRow
      
      'Now to go through the array and return the value in the array
      For intRow = 0 To 392
          If arrArray(intRow, 0) = dteInputDate Then
              ZodiacPeriod = arrArray(intRow, 1)
              Exit For
          End If
      Next intRow
      

      End Function

      I have encountered problems in which a value of 14 is assigned. I have encountered problems in which the requirements are not ma

      R Offline
      R Offline
      riced
      wrote on last edited by
      #2

      Three points. 1. You fill the array with dates starting at index = 1, but with numbers starting at index = 0. Is this correct? 2. You could try something like

      intRow = 0
      For j = 1 to 13
      for i = 1 to 28
      intRow = intRow + 1
      arrArray(intRow,1 ) = j
      next i
      next j

      3. Wrong forum - there is a VB one (though people tend to be VB6 hostile, and this looks like VB6 or VBA to me.) :)

      Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups