VB 2003 and Im still new to vb, so i hope i can explain this as best I can.
I have a variable defined as such: ( simple example )
Dim AVariableOfSorts(,) As Object = _
{ _
{"Last", "String", 20}, _
{"First", "String", 20} _
}
I had to define it as an object so I can have different variable types all
within the same array.
( unless there is another way to do this )
What im getting is an error "Option Strict On Disallows Late Binding" when
I try to do anything with an array element.
For example
AVariableOfSorts(1, 1) = ""
I would like to keep Strict On on
What am I missing ? or how do I get around this issue?
I beleive I know the difference between binding. - Simply put:
1. Dim X as String is early binding and Dim X as Object ,...
X.GetType.ToString would be late binding and would
take longer during running.
Im not sure what to search for in Help / or Online to help myself out.
Thanks
Miro
Herfried K. Wagner [MVP] - 18 Aug 2006 18:48 GMT
"Miro" <mironagy@golden.net> schrieb:
> VB 2003 and Im still new to vb, so i hope i can explain this as best I
> can.
[quoted text clipped - 18 lines]
>
> I would like to keep Strict On on
\\\
DirectCast(AVariableOfSorts(1, 1), String) = ""
///
> What am I missing ? or how do I get around this issue?
Maybe it's better to define a class with properties for the first and second
string and the integer number. Then you can create an array of this type
('Dim Items() As Foo').

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
rmacias - 18 Aug 2006 19:49 GMT
You can try using an ArrayList
Dim listOfObjs As ArrayList = New ArrayList
listOfObjs.Add("Last")
listOfObjs.Add("String")
listOfObjs.Add("20")
However, I like Herfried's idea better in creating a class for this
information and then having an array (or a strongly typed collection) for
them. It really depends on what you are trying to accomplish.
> VB 2003 and Im still new to vb, so i hope i can explain this as best I can.
>
[quoted text clipped - 30 lines]
>
> Miro
tommaso.gastaldi@uniroma1.it - 18 Aug 2006 20:12 GMT
Yes Herfried is right. Go for a class anc collections. Forget about
bidimensional arrays of objects. I have never seen them in a meaningul
.net program.
tommaso
rmacias ha scritto:
> You can try using an ArrayList
>
[quoted text clipped - 42 lines]
> >
> > Miro
Miro - 18 Aug 2006 21:45 GMT
Ive never used classes in the programming languages ive used.
So that is my next lesson.
I stayed away from the array lists cause I didnt like how all the items have
to be the same "var type "
I just want to store a whole bunch of data in 1 variable with many different
vartypes and change the
variable elements as i need to.
Someone once pointed me on this newgroup to the object, so now im at the
point to use the "object" var
i created and im running into this.
So a class it will be - as long as i can achieve the above posted.
I can always make something like "dim bla(,) as String" and strigify
everything and val it as i need to cause i know
which elements are going to be numeric.
I just didnt think it would be this hard to store different variable types
/ variables all in one array.
So im off to read about classes .... my next post might be about them :)
Thanks.
> Yes Herfried is right. Go for a class anc collections. Forget about
> bidimensional arrays of objects. I have never seen them in a meaningul
[quoted text clipped - 53 lines]
>> >
>> > Miro
tommaso.gastaldi@uniroma1.it - 18 Aug 2006 22:01 GMT
Hi Miro. This is not a poetry.
Classes must be your breath.
Arraylist, Hashtable, Sorted List,
your father, mother and brother.
Comparers your best friends ...
Anyone wants to add more lines ? :)
Tommaso
Miro ha scritto:
> Ive never used classes in the programming languages ive used.
>
[quoted text clipped - 78 lines]
> >> >
> >> > Miro
Miro - 18 Aug 2006 23:28 GMT
Believe it or not they arent the easiest thing to grasp.
In theory or on a page or in a book they are fine... but i tell ya
some old languages ive used far too long probably look just as confusing
back.
I will breath Classes this weekend,
and most likely have some questions.
Comparers and friends are still not all that clear either.
M.
> Hi Miro. This is not a poetry.
>
[quoted text clipped - 101 lines]
>> >> >
>> >> > Miro
Cor Ligthert [MVP] - 19 Aug 2006 06:37 GMT
Miro,
Reading your message is the answer, you should not use a programming
language as VB.Net, C#, C++ or Java.
Just keep it by VB script or JavaScript.
Just my thought reading your message.
Cor
> Ive never used classes in the programming languages ive used.
>
[quoted text clipped - 79 lines]
>>> >
>>> > Miro
Miro - 22 Aug 2006 14:22 GMT
I would like to do it all in VB.
Learn it all as one of you would actaully do it in vb.
I knew javascript pretty good back in 99' to about 2002 ... and then i
stopped using it. So Im not sure how much
it has changed since then.
Im fiddling with classes now and I can create a Class and property so im
close ( or i think im close ).
So Im assuming now that I can create property's when im all done I will have
1 Class with 3 properties that will be an array,
that will technically be each element of the array i was trying to create.
M.
ps...
Oh... Herfried K. Wagner... the
DirectCast(AVariableOfSorts(1, 1), String) = "" didnt work, it had the same
issue with late binding or something.
> Miro,
>
[quoted text clipped - 91 lines]
>>>> >
>>>> > Miro
Cor Ligthert [MVP] - 22 Aug 2006 15:46 GMT
Miro,
If you create a class, something as
\\\
Public Class whatever
Private whatevervalue as string
Private whateelsevalue as string
Public property TheFirstValue as string
Get
return whatevervalue
End Get
Set (by value as string)
whatevervalue = value
end set
'The same for secondvalue
End Class
///
Than you can do
Dim myArray as list of (whatever)
all typed in this message so watch typos or other errros.
I hope this helps,
cor
>I would like to do it all in VB.
> Learn it all as one of you would actaully do it in vb.
[quoted text clipped - 110 lines]
>>>>> >
>>>>> > Miro