Sorted Lists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create a sorted list in visual basic.net 2003 with the following statement

Dim myEventInformation As New SortedList(

I am importing Systems, Systems.Collections and Microsoft.VisualBasi

I get compilation errors stating "type expected". I've seen this syntax used in visual basic help, and I'm not sure where I'm going wrong. I am ready to start beating my head against the keyboard. Help Pleeeeease

Miria
 
Hmm, sounds weird indeed. I've just done it a few different ways. I've
used the same Imports statetments you mention.

These all work

Dim sl as new SortedList
Dim sl2 as SortedList = new SortedList
Dim sl3 as new System.Collections.SortedList

One weird thing though. In the MSDN Documentation, the () follow the
instantiation ie Dim s1 as new SortedList() However, in the IDE they aren't
present and if I put them in they disappear...hence the code above was
copied and pasted right from the IDE. In yours, there's parens as there are
in the MSDN docs so you may want to try taking those out.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
Miriam said:
I'm trying to create a sorted list in visual basic.net 2003 with the following statement:

Dim myEventInformation As New SortedList()

I am importing Systems, Systems.Collections and Microsoft.VisualBasic

I get compilation errors stating "type expected". I've seen this syntax
used in visual basic help, and I'm not sure where I'm going wrong. I am
ready to start beating my head against the keyboard. Help Pleeeeease!
 
I've tried dropping the parentheses to no avail. As I type the commands, SortedList comes up as a choice from the VB editor. When I select it and hit return to complete the statement, "SortedList" changes to all lowercase as though it is not recognized, and I get the "type expected" warning. Do I need a specific version of Visual Basic.net to use sorted lists? I'm using Visual Studio.Net professional version

Miriam
 
Okay, I tried the syntax from your third line of sample code

Dim sl3 as new System.Collections.SortedLis

and it worked fine! Weird, eh? Why do I need to specify system.collections if I have it included in the imports section at the top of my module

btw- thanks for the quick reply

Miria
 
Hi Miriam,

Can it be that you have set anywhere in your program a reference to
something that has also a sortedlist as method/propertie/event, than this is
normal?

Cor
 
I do have the following statement later on in my code

Public Function SendList() As sortedlis

(Note that SortedList was rejected and changed to lowercase

The two statements together caused the problem

Miria


----- Cor Ligthert wrote: ----

Hi Miriam

Can it be that you have set anywhere in your program a reference t
something that has also a sortedlist as method/propertie/event, than this i
normal

Co
 
Hi Miriam,

Can you open your solution explorer and than the references.

Or did you make your own class "sortedlist", that can also be the reason.

I am curious what references are there.

Cor
 
Miriam said:
I do have the following statement later on in my code:

Public Function SendList() As sortedlist

(Note that SortedList was rejected and changed to lowercase)

The two statements together caused the problem?

Try menu Edit -> Find&Replace -> Find symbol: Enter sortedlist. What is
found? Here only System.Collections.SortedList is found. Search also for
sortedlist in your code.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Hi Cor

I had named my practice project "sortedlist" -- that was the problem. Good code, terrible naming conventions. Boy, do I feel like a dolt

Thanks for your replies. You definitely put me on the right track

Miria

----- Cor Ligthert wrote: ----

Hi Miriam

Can you open your solution explorer and than the references

Or did you make your own class "sortedlist", that can also be the reason

I am curious what references are there

Co
 
Back
Top