Results 1 to 2 of 2

Thread: Jagged Array (non Variant) possible in VB6?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Jagged Array (non Variant) possible in VB6?

    Background: From a VB6 app, I need to pass a jagged array to a dot net component with a com interface

    The dot net array is structured like this example:
    Code:
    New Double()() {New Double() {0.5, 0.0, 0.4, 0.4, 0.0, -8.0}, _
                          New Double() {0.4, 0.0, 0.3, 0.0, 0.6, -1.0}, _
                          New Double() {0.2, 0.2, 0.0, 0.3, 0.3, -4.0}}
    I tried stuffing double type arrays into individual elements of a variant array in my vb6 app to pass to the dot net app, but the dot net app rejected it with a cant convert object to double error.

    Is there a way to make a true double type jagged array in vb6?

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Jagged Array (non Variant) possible in VB6?

    I'm no pro programmer but I have never come across the term 'jagged array' until now. As far as I can tell it's an array of arrays which you could create in VB6 with a UDT.
    Code:
    Option Explicit
    Private Type tDblArray
       Arr() As Double
    End Type
    
    Private Sub Form_Load()
    Dim D() As tDblArray
       ReDim D(2)
       
       ReDim D(0).Arr(1)
       D(0).Arr(0) = 1.23456
       D(0).Arr(1) = 2
       
       ReDim D(2).Arr(3)
       D(2).Arr(0) = 1
       D(2).Arr(1) = 2
       D(2).Arr(2) = 3.45678
    End Sub
    I think it fits the brief of being jagged but I doubt the structure in memory will be the same, maybe worth a shot though.

    Can a Jagged array hold multiple data types or just one? Is it possible to alter the dimensions of a jagged array once declared?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width