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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Array issue.....plz help

Array issue.....plz help

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabasedata-structures
4 Posts 3 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.
  • M Offline
    M Offline
    mayhem_rules
    wrote on last edited by
    #1

    VB.net / sql myrow = DS.Tables("psrec").Rows(0) '1 record - 24 fields Dim myIntArray(24) As Integer For i = 0 To 23 myIntArray(i) = myrow(i) Next Array.Sort(myIntArray) maxunits = myIntArray(24) wat leaves me stumped is that since the array starts from 0, it should end at 23. However, the maxvalue can be found at myIntArray(24). when i print the array using the code, For i = 0 To 23 Console.WriteLine(myIntArray(i)) Next I always get 0 for myIntArray(0) for every record and the actual values are displayed from myIntArray(1). Therefore, one value is missed since the array prints till myIntArray(23). The last value is at myIntArray(24). Can you explain this to me... With Best Regards, Mayur

    T G 2 Replies Last reply
    0
    • M mayhem_rules

      VB.net / sql myrow = DS.Tables("psrec").Rows(0) '1 record - 24 fields Dim myIntArray(24) As Integer For i = 0 To 23 myIntArray(i) = myrow(i) Next Array.Sort(myIntArray) maxunits = myIntArray(24) wat leaves me stumped is that since the array starts from 0, it should end at 23. However, the maxvalue can be found at myIntArray(24). when i print the array using the code, For i = 0 To 23 Console.WriteLine(myIntArray(i)) Next I always get 0 for myIntArray(0) for every record and the actual values are displayed from myIntArray(1). Therefore, one value is missed since the array prints till myIntArray(23). The last value is at myIntArray(24). Can you explain this to me... With Best Regards, Mayur

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      Since you have Dim myIntArray(24) As Integer For i = 0 To 23 myIntArray(i) = myrow(i) Next you never set the last value in the array, value myIntArray(24) That is the value which is missed? However, I would think the array should end at myIntArray(23) how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06

      1 Reply Last reply
      0
      • M mayhem_rules

        VB.net / sql myrow = DS.Tables("psrec").Rows(0) '1 record - 24 fields Dim myIntArray(24) As Integer For i = 0 To 23 myIntArray(i) = myrow(i) Next Array.Sort(myIntArray) maxunits = myIntArray(24) wat leaves me stumped is that since the array starts from 0, it should end at 23. However, the maxvalue can be found at myIntArray(24). when i print the array using the code, For i = 0 To 23 Console.WriteLine(myIntArray(i)) Next I always get 0 for myIntArray(0) for every record and the actual values are displayed from myIntArray(1). Therefore, one value is missed since the array prints till myIntArray(23). The last value is at myIntArray(24). Can you explain this to me... With Best Regards, Mayur

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        mayhem_rules wrote:

        Dim myIntArray(24) As Integer

        This is an array of 25 items. To declare an array of 24 items you use: Dim myIntArray(23) As Integer The number you supply when declaring an array is not the number of items, but the highest index to be used. I think that there are quite some VB programmers out there who constantly declares arrays that contain one too many items and never realise it, becase it seldom causes any errors. --- b { font-weight: normal; }

        M 1 Reply Last reply
        0
        • G Guffa

          mayhem_rules wrote:

          Dim myIntArray(24) As Integer

          This is an array of 25 items. To declare an array of 24 items you use: Dim myIntArray(23) As Integer The number you supply when declaring an array is not the number of items, but the highest index to be used. I think that there are quite some VB programmers out there who constantly declares arrays that contain one too many items and never realise it, becase it seldom causes any errors. --- b { font-weight: normal; }

          M Offline
          M Offline
          mayhem_rules
          wrote on last edited by
          #4

          Thnk u very much... With Best Regards, Mayur

          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