Hello,
I created a structure ABC and an array of type ABC
Public Structure ABC
Dim str1 As String
Dim int1 As Integer
End Structure
Public ABC1 As New ABC, ABC2 As New ABC
Public ABC3 As New ABC, ABC4 As New ABC
Public arrABC1() As ABC = {ABC1, ABC2}'--this array OK
Public arrABC2() As ABC = {ABC3, ABC4}'--this array OK
Now I want to place arrABC1 and arrABC2 into an array.
How to do this? I tried
Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok
and call it like this
....arrABC(0)(0) to access structure ABC1 -- Not OK here
but I get an error message that I can't do this because
Structure ABC has no default property (option strict on -
must remain on). I could either add a default property to
the structure (how do you do that?) or I could use a
different kind of array type object. I have tried
ArrayList, but that did not work. I tried an Object()
array, but that did not work. Any suggestions appreciated.
Thanks,
Steve 9 1576
Steve, Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok
No! you defined an array of ABC, not an array of array of ABC. arrABC has
ABC1 & ABC3 in it.
Try:
Public arrABC()() As ABC = {arrABC1, arrABC2}
Then will work:
Dim a As ABC = arrABC(0)(0)
Hope this helps
Jay
"Steve" <an*******@discussions.microsoft.com> wrote in message
news:45****************************@phx.gbl... Hello,
I created a structure ABC and an array of type ABC
Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure
Public ABC1 As New ABC, ABC2 As New ABC Public ABC3 As New ABC, ABC4 As New ABC Public arrABC1() As ABC = {ABC1, ABC2}'--this array OK Public arrABC2() As ABC = {ABC3, ABC4}'--this array OK
Now I want to place arrABC1 and arrABC2 into an array. How to do this? I tried
Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok
and call it like this
...arrABC(0)(0) to access structure ABC1 -- Not OK here
but I get an error message that I can't do this because Structure ABC has no default property (option strict on - must remain on). I could either add a default property to the structure (how do you do that?) or I could use a different kind of array type object. I have tried ArrayList, but that did not work. I tried an Object() array, but that did not work. Any suggestions appreciated.
Thanks, Steve
Yes! Thank you very much. I just figured that out before
I got to the post. You concur!
Thanks for your reply.
Steve -----Original Message----- Steve, Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--okNo! you defined an array of ABC, not an array of array of
ABC. arrABC hasABC1 & ABC3 in it.
Try:
Public arrABC()() As ABC = {arrABC1, arrABC2}
Then will work: Dim a As ABC = arrABC(0)(0)
Hope this helps Jay
"Steve" <an*******@discussions.microsoft.com> wrote in
messagenews:45****************************@phx.gbl... Hello,
I created a structure ABC and an array of type ABC
Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure
Public ABC1 As New ABC, ABC2 As New ABC Public ABC3 As New ABC, ABC4 As New ABC Public arrABC1() As ABC = {ABC1, ABC2}'--this array OK Public arrABC2() As ABC = {ABC3, ABC4}'--this array OK
Now I want to place arrABC1 and arrABC2 into an array. How to do this? I tried
Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok
and call it like this
...arrABC(0)(0) to access structure ABC1 -- Not OK here
but I get an error message that I can't do this because Structure ABC has no default property (option strict
on - must remain on). I could either add a default property
to the structure (how do you do that?) or I could use a different kind of array type object. I have tried ArrayList, but that did not work. I tried an Object() array, but that did not work. Any suggestions
appreciated. Thanks, Steve
.
Doh! Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok No! you defined an array of ABC, not an array of array of ABC. arrABC has ABC1 & ABC3 in it.
Damn based 0 indexes ;-) Your arrABC has ABC2 & ABC4 in it...
Glad you got it to work.
Hope this helps
Jay
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2**************@TK2MSFTNGP11.phx.gbl... Steve, Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok No! you defined an array of ABC, not an array of array of ABC. arrABC has ABC1 & ABC3 in it.
Try:
Public arrABC()() As ABC = {arrABC1, arrABC2}
Then will work: Dim a As ABC = arrABC(0)(0)
Hope this helps Jay
"Steve" <an*******@discussions.microsoft.com> wrote in message news:45****************************@phx.gbl... Hello,
I created a structure ABC and an array of type ABC
Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure
Public ABC1 As New ABC, ABC2 As New ABC Public ABC3 As New ABC, ABC4 As New ABC Public arrABC1() As ABC = {ABC1, ABC2}'--this array OK Public arrABC2() As ABC = {ABC3, ABC4}'--this array OK
Now I want to place arrABC1 and arrABC2 into an array. How to do this? I tried
Public arrABC() As ABC = {arrABC1(1), arrABC2(1)}'--ok
and call it like this
...arrABC(0)(0) to access structure ABC1 -- Not OK here
but I get an error message that I can't do this because Structure ABC has no default property (option strict on - must remain on). I could either add a default property to the structure (how do you do that?) or I could use a different kind of array type object. I have tried ArrayList, but that did not work. I tried an Object() array, but that did not work. Any suggestions appreciated.
Thanks, Steve
Steve,
In addition to Jay,
A very easy way of making an array of arrays is using the arraylist.
And than use the directcast when you are using it.
When you want a example of that tell that.
Cor
Thanks. Yes. How would you cast this using Arraylists?
I tried arraylist with no luck
Dim arrL() As New ArrayList
arrl(1) = CType(ABC1(x), ABC)
arrl(2) = CType(ABC2(x), ABC)
....
something like that? Is there a benefit to using
ArrayLists over just creating an Array of Type ABC? -----Original Message----- Steve,
In addition to Jay,
A very easy way of making an array of arrays is using
the arraylist. And than use the directcast when you are using it.
When you want a example of that tell that.
Cor
.
Steve,
Here 2 samples of me, The first is arraylist array, where is some
explaination the second an arraylist arraylist
When the array is static, than you can (should) use the standard Array, when
the array is dynamic you should in my opinion never take the standard Array
I hope they help?
Cor
\\\arraylist array
Option Strict On
Public Module Main
' Sample of an arraylist that itself contains 10 classic arrays.
Public Sub Main()
Dim x As New ArrayList
Dim y() As Integer = {1, 2, 3, 4}
For i As Integer = 0 To 9
x.Add(y)
Next
MessageBox.Show(DirectCast(x(9), IList)(2).ToString)
'With option strict off you do not
'have to use the directcast and than it is
'MessageBox.Show(a(2)(2).ToString) 'but I would not do that
'I show this above to make it more classic looking for you.
'The Insert
Dim yN() As Integer = {5, 6, 7, 8}
x.Insert(1, yN)
MessageBox.Show(DirectCast(x(1), IList)(2).ToString)
End Sub
End Module
///
\\\arraylist arraylist
Dim x As New ArrayList
For i As Integer = 0 To 9
Dim y As New ArrayList
For j As Integer = 0 To 4
y.Add(Chr(j + 65))
Next
x.Add(y)
Next
MessageBox.Show(DirectCast(x(2), ArrayList)(2).ToString)
Dim yN As New ArrayList
For j As Integer = 0 To 4
yN.Add(Chr(j + 75))
Next
x.Insert(1, yN)
MessageBox.Show(DirectCast(x(1), ArrayList)(2).ToString)
///
"Steve" <an*******@discussions.microsoft.com> Thanks. Yes. How would you cast this using Arraylists?
I tried arraylist with no luck
Dim arrL() As New ArrayList arrl(1) = CType(ABC1(x), ABC) arrl(2) = CType(ABC2(x), ABC) ...
something like that? Is there a benefit to using ArrayLists over just creating an Array of Type ABC?
-----Original Message----- Steve,
In addition to Jay,
A very easy way of making an array of arrays is using the arraylist. And than use the directcast when you are using it.
When you want a example of that tell that.
Cor
.
Hi Cor,
Thanks for the example. So, to get this straight, if I do
ArrayList.Add(y)
that adds an element sequentially,
and
ArrayList.Insert(n, m)
adds an element at a selected index n? -----Original Message----- Steve,
Here 2 samples of me, The first is arraylist array, where
is someexplaination the second an arraylist arraylist
When the array is static, than you can (should) use the
standard Array, whenthe array is dynamic you should in my opinion never take
the standard Array I hope they help?
Cor
\\\arraylist array Option Strict On Public Module Main ' Sample of an arraylist that itself contains 10
classic arrays. Public Sub Main() Dim x As New ArrayList Dim y() As Integer = {1, 2, 3, 4} For i As Integer = 0 To 9 x.Add(y) Next MessageBox.Show(DirectCast(x(9), IList)
(2).ToString) 'With option strict off you do not 'have to use the directcast and than it is 'MessageBox.Show(a(2)(2).ToString) 'but I would
not do that 'I show this above to make it more classic
looking for you.'The Insert Dim yN() As Integer = {5, 6, 7, 8} x.Insert(1, yN) MessageBox.Show(DirectCast(x(1), IList)
(2).ToString) End Sub End Module /// \\\arraylist arraylist Dim x As New ArrayList For i As Integer = 0 To 9 Dim y As New ArrayList For j As Integer = 0 To 4 y.Add(Chr(j + 65)) Next x.Add(y) Next MessageBox.Show(DirectCast(x(2), ArrayList)(2).ToString) Dim yN As New ArrayList For j As Integer = 0 To 4 yN.Add(Chr(j + 75)) Next x.Insert(1, yN) MessageBox.Show(DirectCast(x(1), ArrayList)(2).ToString) ///
"Steve" <an*******@discussions.microsoft.com>
Thanks. Yes. How would you cast this using Arraylists?
I tried arraylist with no luck
Dim arrL() As New ArrayList arrl(1) = CType(ABC1(x), ABC) arrl(2) = CType(ABC2(x), ABC) ...
something like that? Is there a benefit to using ArrayLists over just creating an Array of Type ABC?
-----Original Message----- Steve,
In addition to Jay,
A very easy way of making an array of arrays is using the arraylist. And than use the directcast when you are using it.
When you want a example of that tell that.
Cor
.
.
Steve,
Try this maybe this is easier to understand.
However every row (arraylist) can be of a different lenght keep that in mind
\\\
Dim x As New ArrayList
For i As Integer = 0 To 9
Dim y As New ArrayList
For j As Integer = 0 To 4
y.Add("")
Next
x.Add(y)
Next
DirectCast(x(2), ArrayList)(2) = "Steve"
MessageBox.Show(DirectCast(x(2), ArrayList)(2).ToString)
////
I hope this helps?
Cor
Yes. Thank you. I think I'm getting it now. It is the
DirectCast part that I was missing before. Now I got it.
Thanks. -----Original Message----- Steve,
Try this maybe this is easier to understand. However every row (arraylist) can be of a different
lenght keep that in mind\\\ Dim x As New ArrayList For i As Integer = 0 To 9 Dim y As New ArrayList For j As Integer = 0 To 4 y.Add("") Next x.Add(y) Next DirectCast(x(2), ArrayList)(2) = "Steve" MessageBox.Show(DirectCast(x(2), ArrayList)(2).ToString) ////
I hope this helps?
Cor
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: M.Siler |
last post by:
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT>
<!--
var factor_val = new Array(8,7)
factor_val = 68.8
factor_val = 55
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: Michael |
last post by:
Hi,
I am trying to pass a function an array of strings, but I am having trouble
getting the indexing to index the strings rather than the individual
characters of one of the strings.
I have...
|
by: buuuuuum |
last post by:
why array can't be assigned, like structs?
| |
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need...
|
by: dan |
last post by:
I would like to have the preprocessor automatically generate the
number of array elements requested. Each element is zero. The elements
get pasted into a larger array. The other elements may be...
|
by: chiefychf |
last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
|
by: Slain |
last post by:
I need to convert a an array to a multidimensional one. Since I need
to wrok with existing code, I need to modify a declaration which looks
like this
In the .h file
int *x;
in a initialize...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |