ListBoxes and Arrays

ListBoxes and Arrays

Anonymous
Not applicable
593 Views
7 Replies
Message 1 of 8

ListBoxes and Arrays

Anonymous
Not applicable
OK this is strange.

I started a project in VBA to easily design a form to interact with IV.

I then moved it all to VB and the form came in as a Designer (?) not a form.
Seems to work fine however.

In the form code I have a 2D array arProps(0 to x, 0 to x)

To load a 2 column listbox with items from the array I simply use:

ListBox2.List = arProps() which works great

So I now add a new form (which is under the Form area now) and I use a
similar 2D array arProps2(0 to x, 0 to x)

but when I try to load a listbox in this form via

ListBOx3.List = arProps2()

I get a Argument not optional error on compile...

I'm really confused now...

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
"...and quit driving 50MPH in the left lane!!!"
-----------------------------------------------------------------------
0 Likes
594 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I think you might have to use Additem instead. Maybe something like this where i and j
are the two values of the array


Dim i, j As Integer
For i = 0 To 2
For j = 0 To 2
List1.AddItem ar(i, j)
Next
Next


--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"Sean Dotson" wrote in message
news:821283EA2D4FADEEE7FD2DE7B3064E2D@in.WebX.maYIadrTaRb...
> OK this is strange.
>
> I started a project in VBA to easily design a form to interact with IV.
>
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Sure but I wonder why it works in one form and not the other? Could the VBA
form have different syntax from the VB form even though they are both in
VB?

And isn't the previous syntax much cleaner. You'd think VB would have a
better syntax than VBA..

Very odd..

Thanks regardless..

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
----------------------------------------------------------------------------
------
"Kent Keller" wrote in message
news:A688568B1109713D0D77BC9980964450@in.WebX.maYIadrTaRb...
> I think you might have to use Additem instead. Maybe something like this
where i and j
> are the two values of the array
>
>
> Dim i, j As Integer
> For i = 0 To 2
> For j = 0 To 2
> List1.AddItem ar(i, j)
> Next
> Next
>
>
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
> "Sean Dotson" wrote in message
> news:821283EA2D4FADEEE7FD2DE7B3064E2D@in.WebX.maYIadrTaRb...
> > OK this is strange.
> >
> > I started a project in VBA to easily design a form to interact with IV.
> >
> >
>
>
0 Likes
Message 4 of 8

Anonymous
Not applicable
Hmm.. this actually loads it into one column in the listbox.

So it looks like this..

Item1
Item1
Item2
Item2

insted of

Item1 Item1
Item2 Item2

sure looks like VBA has a much simpler way to do this...

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
"...and quit driving 50MPH in the left lane!!!"
-----------------------------------------------------------------------
"Kent Keller" wrote in message
news:A688568B1109713D0D77BC9980964450@in.WebX.maYIadrTaRb...
> I think you might have to use Additem instead. Maybe something like this
where i and j
> are the two values of the array
>
>
> Dim i, j As Integer
> For i = 0 To 2
> For j = 0 To 2
> List1.AddItem ar(i, j)
> Next
> Next
>
>
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
> "Sean Dotson" wrote in message
> news:821283EA2D4FADEEE7FD2DE7B3064E2D@in.WebX.maYIadrTaRb...
> > OK this is strange.
> >
> > I started a project in VBA to easily design a form to interact with IV.
> >
> >
>
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
Sean,

Here is the simple answer [and the confusion]. Read this carefully please. VB and VBA are environments in which you make use of the Visual Basic programming language. Notice how I worded that sentence. Controls [of which a form is] are NOT the same at all. There is a ListBox control for VB and there is another ListBox for VBA and things do not always work the same. I ran into your exact situation some time back so I know what you're saying.

Does this make it any clearer?

Joe
--
0 Likes
Message 6 of 8

Anonymous
Not applicable
Yes OK that does make sense.

I guess the default control for a listbox in VBA is different from the
default in VB. (From what I have read, and your statement confirms that).

Is there an easy way to use the listbox control from VBA in VB? What
controls toolbox would need to be loaded?

Could this possibly present problem when distributing the app? I would
assume no as if the user has IV they would have the VBA controls (and
associated dlls etc..)

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
"...and quit driving 50MPH in the left lane!!!"
-----------------------------------------------------------------------
"joesu" wrote in message
news:f17055e.3@WebX.maYIadrTaRb...
> Sean,
> Here is the simple answer [and the confusion]. Read this carefully please.
VB and VBA are environments in which you make use of the Visual Basic
programming language. Notice how I worded that sentence. Controls [of which
a form is] are NOT the same at all. There is a ListBox control for VB and
there is another ListBox for VBA and things do not always work the same. I
ran into your exact situation some time back so I know what you're saying.
>
> Does this make it any clearer?
>
> Joe
> --
>
0 Likes
Message 7 of 8

Anonymous
Not applicable
You noticed when you opened your IV-VBA form in VB you were presented with the default set of intrinsic controls. These controls will only appear when you are using the Microsoft Forms Designer. Otherwise, you are presented with the default VB intrinsic controls. I don't of a method of using the VBA controls in a VB app or vice versa. I believe I tried it and was presented with naming conflict errors. And since there are certain libraries you cannot remove from the list of references, my inclination would be to say you cannot do it. HTH.

Joe
--
0 Likes
Message 8 of 8

Anonymous
Not applicable
OK, just looks like I'll have to code around it.

It's a pity as the VBA form of the list box has a lot of powerful
properties...

Thanks,
--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
"joesu" wrote in message
news:f17055e.5@WebX.maYIadrTaRb...
> You noticed when you opened your IV-VBA form in VB you were presented with
the default set of intrinsic controls. These controls will only appear when
you are using the Microsoft Forms Designer. Otherwise, you are presented
with the default VB intrinsic controls. I don't of a method of using the VBA
controls in a VB app or vice versa. I believe I tried it and was presented
with naming conflict errors. And since there are certain libraries you
cannot remove from the list of references, my inclination would be to say
you cannot do it. HTH.
> Joe
> --
>
0 Likes