Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Nathan03
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Texas
Posted: 14th May 2009 00:46
Im trying to make a gui system for my project im stuck trying to figure out a way of storing arrays or a collection within a type? here's what im trying to do below but this is not allowed in dbpro it seems. Thanks!!

Type TListBox
Control As TControl
Dim Items(0) As String
EndType
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 14th May 2009 02:03
You can't have 0 dimension arrays...

Dim array(1) is the lowest, and array(0) will be created.

That one means how many there are, including the zero.

Also, can you use arrays in types?

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 14th May 2009 02:10 Edited at: 14th May 2009 02:13
Quote: "You can't have 0 dimension arrays..."


Assuming you mean indices rather than dimensions, then yes you can. Dim MyArray(-1) or simply Dim MyArray() will create an array with 0 indices. Dim MyArray(0) will create an array with one index: MyArray(0). Dim MyArray(1) will create an array with two indices: MyArray(0), and MyArray(2).

Quote: "Also, can you use arrays in types?"


Nope.

i like orange
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 17th May 2009 01:06
Quote: "Nope."


While it's true you can't use DBPro arrays in types, you can create your own. Since the little bit of code that Nathan03 posted used strings in an array, I wrote a little example using strings as well, but the technique can be tweaked to hold any type of data. Here:


Since you can have other UDT fields in UDTs, you can now take this "array" type and put it in your original type like so:



It's been a couple of days, so you might have worked around the problem another way, but if not, you could make this work.
Nathan03
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Texas
Posted: 18th May 2009 23:47
Thanks Kira!! Your solution looks like it will work perfect for my project!!

Login to post a reply

Server time is: 2024-09-28 06:27:51
Your offset time is: 2024-09-28 06:27:51