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. how to pass a two dimensional dynamic array in a function

how to pass a two dimensional dynamic array in a function

Scheduled Pinned Locked Moved Visual Basic
helpdata-structurestutorialquestion
5 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.
  • J Offline
    J Offline
    jainiraj
    wrote on last edited by
    #1

    hi to all.. I have two dynamic array bOdt and bodtEntry byte arrays. which are declared as follow- Dim bOdt() As Byte Dim bOdtzentry() As Byte and I am passing BOdt in a function as two dimension array but still it is dynamic.Now I want to store this bOdt array in another array bOdtEntry and change size of the array. My code is as follow- Public Function fOdtEntry(count As Integer, bOdt() As Byte) As Variant Dim FlagRem As Integer Dim FlagDiv As Integer Dim RefCntr As Byte ReDim bOdtEntry(0 To count, 0 To 9) As Byte bOdtEntry = bOdt bOdtEntry(count, 0) = bGet(8) bOdtEntry(count, 1) = bGet(9) and so on.. On compilation it is giving an error."Subscribe out of range" Plz help what may be the problemmmmm?? Thanks in adv.

    D 1 Reply Last reply
    0
    • J jainiraj

      hi to all.. I have two dynamic array bOdt and bodtEntry byte arrays. which are declared as follow- Dim bOdt() As Byte Dim bOdtzentry() As Byte and I am passing BOdt in a function as two dimension array but still it is dynamic.Now I want to store this bOdt array in another array bOdtEntry and change size of the array. My code is as follow- Public Function fOdtEntry(count As Integer, bOdt() As Byte) As Variant Dim FlagRem As Integer Dim FlagDiv As Integer Dim RefCntr As Byte ReDim bOdtEntry(0 To count, 0 To 9) As Byte bOdtEntry = bOdt bOdtEntry(count, 0) = bGet(8) bOdtEntry(count, 1) = bGet(9) and so on.. On compilation it is giving an error."Subscribe out of range" Plz help what may be the problemmmmm?? Thanks in adv.

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      If you are using Option Base 0 then count will be 1 higher than the upperbound index. you should not use fixed values, but use Ubound and if you do use count then subtract 1 for the highest index.

      Dave Don't forget to rate messages!
      Find Me On: Web|Facebook|Twitter|LinkedIn

      J 1 Reply Last reply
      0
      • D DaveAuld

        If you are using Option Base 0 then count will be 1 higher than the upperbound index. you should not use fixed values, but use Ubound and if you do use count then subtract 1 for the highest index.

        Dave Don't forget to rate messages!
        Find Me On: Web|Facebook|Twitter|LinkedIn

        J Offline
        J Offline
        jainiraj
        wrote on last edited by
        #3

        thanks for replay.. But i am not getting it. I am using base 0 and count is the ubound of array.... Can u explained in detail.. Thanks

        D 1 Reply Last reply
        0
        • J jainiraj

          thanks for replay.. But i am not getting it. I am using base 0 and count is the ubound of array.... Can u explained in detail.. Thanks

          D Offline
          D Offline
          DaveAuld
          wrote on last edited by
          #4

          If you are using Base 0 then look at the following example for an array called Names; Index - Item ------------- 0 - Fred 1 - Jim 2 - Bob 3 - Frank 4 - Jack Count = 5, LBound = 0, UBound = 4 So, Names(0) = Fred Names(4) = Jack Names(Count-1) = Jack Names(Count) = Out Of Limits Error Does that explain it better?

          Dave Don't forget to rate messages!
          Find Me On: Web|Facebook|Twitter|LinkedIn

          J 1 Reply Last reply
          0
          • D DaveAuld

            If you are using Base 0 then look at the following example for an array called Names; Index - Item ------------- 0 - Fred 1 - Jim 2 - Bob 3 - Frank 4 - Jack Count = 5, LBound = 0, UBound = 4 So, Names(0) = Fred Names(4) = Jack Names(Count-1) = Jack Names(Count) = Out Of Limits Error Does that explain it better?

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn

            J Offline
            J Offline
            jainiraj
            wrote on last edited by
            #5

            thanks for ur reply.. I got the solution.. :)

            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