Home All Groups Group Topic Archive Search About

Array Problems - still cant get something set up right.

Author
14 Jun 2006 2:20 PM
Miro
I have code like this:
( I have modified it a bit so it makes sence on this board )  - I hope this
next part makes sence.

I am trying to create a multi-dimension array, that has multiple columns.
Yes It will be a Jagged array, but if this is not possible in this situation
ill just have NIL columns ( not a problem ).

I basically want this to be an array that will bee   X big, Y Long, and 6
wide... so    Array( X, Y, 6 )
X i will determine from a different variable in the program.  So lets say in
this example it will be 2.
Y By default will be set to 100 for example.  But the program will stop if
it hits some nill values after.

The reasoning for this, is I am (trying) writing code to add in some fields
to tables if the field / or table
doesnt exist.  This will be set up ( hardcoded ) in an array of all my
fields in every database / table.
** Its a long story of why I want to do this but you want to know, see
attached.



Dim aSystemTableSpecs( , ) As String

aSystemTableSpecs(1,1) = {"1", "MDBFileName", "System", "Version", "N", "3"}

aSystemTableSpecs(1,2) = {"1", "~PlaceHolderString~" }

aSystemTableSpecs(2,1) = {"1", "MDBFileName", "Person", "FirstName", "C",
"20"}

aSystemTableSpecs(2,2) = {"1", "MDBFileName", "Person", "LastName", "C",
"20"}

aSystemTableSpecs(2,3) = {"1", "~PlaceHolderString~" }



However I get an "Expression Expected" on the opening squiggly ' { '

Am i wrong to try to use an array?  I have started reading up on collections
but i dont think that would work either.

It would be nice if I could use different Variable Types within each sub
element of the array so for example:

aSystemTableSpecs(1) = {1, "ReferenceString", "System", "Version", "N", 3}


Thanks in Advance.


[attached file: Re_ Final Post of the day - Array.nws]

Author
14 Jun 2006 9:31 PM
GhostInAK
Hello Miro,

Yeesh.  Your data types are all hosed.

You want to create your variable as such:
Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As String
This produced a 2-dimentional array of an array of strings. 

Or

Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count, DimentionThree_Count)
As String
This produces a 3-dimentional array.


Second, you can NOT use array instantiation code as an assignment.  (ie,
you may ONLY use curly braces to define an array during array instantiation).

-Boo


Show quoteHide quote
> Dim aSystemTableSpecs( , ) As String
>
> aSystemTableSpecs(1,1) = {"1", "MDBFileName", "System", "Version",
> "N", "3"}
Author
15 Jun 2006 3:04 PM
Miro
Ha,
I havnt heard the word "Hosed" for a long time.  I enjoyed that.

So this part i understand -
> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As String

does that mean in assignment I have to assign every one separetly?
Like:

aSystemTableSpecs(1,1) = "Hi"
aSystemTableSpecs(1,2) = "bye"
aSystemTableSpecs(1,3) = "another string"

aSystemTableSpecs(2,1) = "Good Day"
aSystemTableSpecs(2,2) = "Hosed"
... and so on?

I was trying to find a way ( searchin the net ) to see if i can assign
everything in 1 line for an array per Dimension1_Count

Thats how I cam accross in my google searching a Collection... something
like this:
Dim States As New Collection
States.Add("AL","Alabama")
States.Add("AK","Alaska")
States.Add("AZ","Arizona")

Thats kinda how i am looking for a way to add the arrays, not element by
element but all the Y elements per X element. "( X, Y )"


Still Smilin.

Miro




Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:be1391bf69728c85dcdf4646eaf@news.microsoft.com...
> Hello Miro,
>
> Yeesh.  Your data types are all hosed.
>
> You want to create your variable as such:
> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As String
> This produced a 2-dimentional array of an array of strings.
> Or
>
> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count,
> DimentionThree_Count) As String
> This produces a 3-dimentional array.
>
>
> Second, you can NOT use array instantiation code as an assignment.  (ie,
> you may ONLY use curly braces to define an array during array
> instantiation).
>
> -Boo
>
>
>> Dim aSystemTableSpecs( , ) As String
>>
>> aSystemTableSpecs(1,1) = {"1", "MDBFileName", "System", "Version",
>> "N", "3"}
>
>
>
Author
15 Jun 2006 7:49 PM
GhostInAK
Hello Miro,

I certainly don't know your design contraints or criteria.. however it really
sounds like a structure or class would serve you well..
Anyhow.. continuing with arrays..

Dim tTableSpecs(10,10)() As String

Sub Main

tTableSpecs(x,y) = MakeArray("Who's", "Yo", "Daddy")

End Sub


Function MakeArray(ParamArray tValues AS String) As String()

Dim tReturn(tValues.GetUpperBounds(0)-1) As String
Dim tCount as integer=0

'    This copying of elements may be unnesseccary, I have not delved into it.
For tCount=0 to tValues.GetUpperBounds(0)-1
tReturn(tCount) = tValues(tCount)    
Next

return tReturn

End Function

Show quoteHide quote
> Ha,
> I havnt heard the word "Hosed" for a long time.  I enjoyed that.
> So this part i understand -
>
>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As
>> String
>>
> does that mean in assignment I have to assign every one separetly?
> Like:
>
> aSystemTableSpecs(1,1) = "Hi"
> aSystemTableSpecs(1,2) = "bye"
> aSystemTableSpecs(1,3) = "another string"
> aSystemTableSpecs(2,1) = "Good Day"
> aSystemTableSpecs(2,2) = "Hosed"
> .. and so on?
> I was trying to find a way ( searchin the net ) to see if i can assign
> everything in 1 line for an array per Dimension1_Count
>
> Thats how I cam accross in my google searching a Collection...
> something
> like this:
> Dim States As New Collection
> States.Add("AL","Alabama")
> States.Add("AK","Alaska")
> States.Add("AZ","Arizona")
> Thats kinda how i am looking for a way to add the arrays, not element
> by element but all the Y elements per X element. "( X, Y )"
>
> Still Smilin.
>
> Miro
>
> "GhostInAK" <ghosti***@gmail.com> wrote in message
> news:be1391bf69728c85dcdf4646eaf@news.microsoft.com...
>
>> Hello Miro,
>>
>> Yeesh.  Your data types are all hosed.
>>
>> You want to create your variable as such:
>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As
>> String
>> This produced a 2-dimentional array of an array of strings.
>> Or
>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count,
>> DimentionThree_Count) As String
>> This produces a 3-dimentional array.
>> Second, you can NOT use array instantiation code as an assignment.
>> (ie, you may ONLY use curly braces to define an array during array
>> instantiation).
>>
>> -Boo
>>
>>> Dim aSystemTableSpecs( , ) As String
>>>
>>> aSystemTableSpecs(1,1) = {"1", "MDBFileName", "System", "Version",
>>> "N", "3"}
>>>
Author
16 Jun 2006 5:31 AM
Miro
I never even would have considered making a function to split up the param
and making an array.
I like that idea.

I am slowely teaching myself vb while working with some old 4GL languanges,
so Structures and Classes are a bit new
to me.
I will read up on structures or classes.

Once i get a basic prog working then ill start going back and modifying it
and hopefully by that time i know all about
structures or classes.  Slowly im learning the basics, with arrays and stuff
and what i find in google and this newgroup which
I must say is one of the handiest things ever and thanks to everyone who has
answerd my questions so far, and hopfully in some
time ill be answering peoples quesitons on the newsgroup.

And the 'whos ur daddy' comment was awsome.  Easy and funny examples will
always help u remember in the long run.

Thanks..
Question solved.

Miro



Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:be1391bf6b8c8c85e88f6f34087@news.microsoft.com...
> Hello Miro,
>
> I certainly don't know your design contraints or criteria.. however it
> really sounds like a structure or class would serve you well..
> Anyhow.. continuing with arrays..
>
> Dim tTableSpecs(10,10)() As String
>
> Sub Main
>
> tTableSpecs(x,y) = MakeArray("Who's", "Yo", "Daddy")
>
> End Sub
>
>
> Function MakeArray(ParamArray tValues AS String) As String()
>
> Dim tReturn(tValues.GetUpperBounds(0)-1) As String
> Dim tCount as integer=0
>
> '    This copying of elements may be unnesseccary, I have not delved into
> it.
> For tCount=0 to tValues.GetUpperBounds(0)-1
> tReturn(tCount) = tValues(tCount)     Next
>
> return tReturn
>
> End Function
>
>> Ha,
>> I havnt heard the word "Hosed" for a long time.  I enjoyed that.
>> So this part i understand -
>>
>>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As
>>> String
>>>
>> does that mean in assignment I have to assign every one separetly?
>> Like:
>>
>> aSystemTableSpecs(1,1) = "Hi"
>> aSystemTableSpecs(1,2) = "bye"
>> aSystemTableSpecs(1,3) = "another string"
>> aSystemTableSpecs(2,1) = "Good Day"
>> aSystemTableSpecs(2,2) = "Hosed"
>> .. and so on?
>> I was trying to find a way ( searchin the net ) to see if i can assign
>> everything in 1 line for an array per Dimension1_Count
>>
>> Thats how I cam accross in my google searching a Collection...
>> something
>> like this:
>> Dim States As New Collection
>> States.Add("AL","Alabama")
>> States.Add("AK","Alaska")
>> States.Add("AZ","Arizona")
>> Thats kinda how i am looking for a way to add the arrays, not element
>> by element but all the Y elements per X element. "( X, Y )"
>>
>> Still Smilin.
>>
>> Miro
>>
>> "GhostInAK" <ghosti***@gmail.com> wrote in message
>> news:be1391bf69728c85dcdf4646eaf@news.microsoft.com...
>>
>>> Hello Miro,
>>>
>>> Yeesh.  Your data types are all hosed.
>>>
>>> You want to create your variable as such:
>>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count)() As
>>> String
>>> This produced a 2-dimentional array of an array of strings.
>>> Or
>>> Dim aSystemTableSpecs(Dimension1_Count, DimentionTwo_Count,
>>> DimentionThree_Count) As String
>>> This produces a 3-dimentional array.
>>> Second, you can NOT use array instantiation code as an assignment.
>>> (ie, you may ONLY use curly braces to define an array during array
>>> instantiation).
>>>
>>> -Boo
>>>
>>>> Dim aSystemTableSpecs( , ) As String
>>>>
>>>> aSystemTableSpecs(1,1) = {"1", "MDBFileName", "System", "Version",
>>>> "N", "3"}
>>>>
>
>