vb6 and arrays of shape

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rose Alit,mon mignon

    vb6 and arrays of shape

    Hi,
    I'm trying the following and doesn't work.
    Could someone have any clue?

    dim arrMyShapes(1 to MxA,1 to MxB) of New Shape

    Thanks

    JeanM


  • Bob Butler

    #2
    Re: vb6 and arrays of shape

    "Rose Alit,mon mignon" <sruojlim@yahoo .ca> wrote in message news:<AS5ac.150 23$1A6.691497@n ews20.bellgloba l.com>...[color=blue]
    > Hi,
    > I'm trying the following and doesn't work.
    > Could someone have any clue?
    >
    > dim arrMyShapes(1 to MxA,1 to MxB) of New Shape[/color]

    try it like this

    Dim MxA As Long
    Dim MxB As Long
    MxA = 10
    MxB = 10
    Dim x&, y As Long
    Dim arrMyShapes() As Shape
    ReDim arrMyShapes(1 To MxA, 1 To MxB)
    For x = 1 To MxA
    For y = 1 To MxB
    Set arrMyShapes(x, y) = New Shape
    Next
    Next

    Comment

    • Rick Rothstein

      #3
      Re: vb6 and arrays of shape

      > > I'm trying the following and doesn't work.[color=blue][color=green]
      > > Could someone have any clue?
      > >
      > > dim arrMyShapes(1 to MxA,1 to MxB) of New Shape[/color]
      >
      > try it like this
      >
      > Dim MxA As Long
      > Dim MxB As Long
      > MxA = 10
      > MxB = 10
      > Dim x&, y As Long
      > Dim arrMyShapes() As Shape
      > ReDim arrMyShapes(1 To MxA, 1 To MxB)
      > For x = 1 To MxA
      > For y = 1 To MxB
      > Set arrMyShapes(x, y) = New Shape
      > Next
      > Next[/color]

      VB does not like the way you are using New. Are you sure this doesn't have
      to be a control array (Shape is a standard VB control) with an X/Y formula
      (or Row/Col or whatever) to imitate 2D referencing?

      Rick - MVP


      Comment

      • Rose Alit,mon mignon

        #4
        Re: vb6 and arrays of shape

        Thank you Bob for answering...but doesn't seem to work. I got a message
        saying "wrong use of NEW"

        Otherwise how could i define a new shape control at runtime?

        Thanks for help

        "Bob Butler" <butlerbob@eart hlink.net> a écrit dans le message de
        news:fa10fb0.04 03300736.f968d1 8@posting.googl e.com...[color=blue]
        > "Rose Alit,mon mignon" <sruojlim@yahoo .ca> wrote in message[/color]
        news:<AS5ac.150 23$1A6.691497@n ews20.bellgloba l.com>...[color=blue][color=green]
        > > Hi,
        > > I'm trying the following and doesn't work.
        > > Could someone have any clue?
        > >
        > > dim arrMyShapes(1 to MxA,1 to MxB) of New Shape[/color]
        >
        > try it like this
        >
        > Dim MxA As Long
        > Dim MxB As Long
        > MxA = 10
        > MxB = 10
        > Dim x&, y As Long
        > Dim arrMyShapes() As Shape
        > ReDim arrMyShapes(1 To MxA, 1 To MxB)
        > For x = 1 To MxA
        > For y = 1 To MxB
        > Set arrMyShapes(x, y) = New Shape
        > Next
        > Next[/color]


        Comment

        • J French

          #5
          Re: vb6 and arrays of shape

          On Tue, 30 Mar 2004 23:05:53 -0500, "Rose Alit,mon mignon"
          <sruojlim@yahoo .ca> wrote:
          [color=blue]
          >Thank you Bob for answering...but doesn't seem to work. I got a message
          >saying "wrong use of NEW"
          >
          >Otherwise how could i define a new shape control at runtime?
          >[/color]

          As Rick suggested, you would be wise to use a Control Array, that way
          to create a new Shape at runtime you simply Load shpArray( N )

          However for convenience, there is no reason why you should not have a
          two dimensional Array that refers to the iterms in the Control Array

          Set shpMatrix( 1, 1 ) = shpArray( 1 )

          Comment

          • Bob Butler

            #6
            Re: vb6 and arrays of shape

            "Rose Alit,mon mignon" <sruojlim@yahoo .ca> wrote in message news:<Esrac.504 08$1A6.1088623@ news20.bellglob al.com>...[color=blue]
            > Thank you Bob for answering...but doesn't seem to work. I got a message
            > saying "wrong use of NEW"
            >
            > Otherwise how could i define a new shape control at runtime?[/color]

            Sorry, for some reason "Shape" didn't register as a control type and I
            was just assuming you had an object called 'Shape' in your app. Rick
            and J French provided better responses given that you are trying to
            get an array of controls.

            Comment

            Working...