By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,464 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,464 IT Pros & Developers. It's quick & easy.

Sorted Lists

P: n/a
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

Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
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!
Miriam

Nov 20 '05 #2

P: n/a
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
Nov 20 '05 #3

P: n/a
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
Nov 20 '05 #4

P: n/a
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
Nov 20 '05 #5

P: n/a
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

Nov 20 '05 #6

P: n/a
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
Nov 20 '05 #7

P: n/a
"Miriam" <an*******@discussions.microsoft.com> schrieb
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

Nov 20 '05 #8

P: n/a
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

Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.