PDA

View Full Version : VB - Organize a listbox alphabetically



Lorem-Ipsum
22-09-10, 18:01
Just started VB today. Not too keen on it. Its not backwards compatible and documentation isn't brilliant.

Anyway I have to make a listbox with a few buttons which was easy.

The problem is, when a new item is added to the listbox it needs to be ordered alphabetically.

Not really sure how to do this.

Any ideas?

DoubleTop
22-09-10, 18:19
vb6 ? A homework question by any chance?

Pointer .... there is a little dropdown item when you click on the control on your form, iirc it's called sorted and is either true or false :D

DT.

Lorem-Ipsum
22-09-10, 18:45
I'm doing a foundation degree and we're using Visual Studio 2010 which is a bit different to 2008 which is what I practiced on.

I'm used to using other programming languages and VB isn't too tidy.

Thanks for that. I'm using the family PC for VB until I set up the windows box so I'll check when my sister gets off it later.

Lorem-Ipsum
22-09-10, 19:25
AS I want to run it when I add a new item I put it in the listbox sub. It runs along the lines of:


listBox1.Sorted = True

Peter
22-09-10, 21:50
Eww VB. Had to use VB.NET In my college classes for Computing.

Lorem-Ipsum
22-09-10, 22:09
I use linux so I know a nice mix of shell script and python. Nice and simple and gets to the point.

I also know a bit of C and some BASIC and had to learn assembly for my electronics course, doubt I could do anything with it now.

DoubleTop
22-09-10, 22:16
teehee, it's a lot harder than that in vb.net :D

DT.

Peter
22-09-10, 22:26
I use linux so I know a nice mix of shell script and python. Nice and simple and gets to the point.

I also know a bit of C and some BASIC and had to learn assembly for my electronics course, doubt I could do anything with it now.

I use Linux on my VPS so I also have experience with Shell Scripting, however I don't use any Python. I'm mainly a web developer (no design, just backend) so I know:
HTML
JavaScript
Some CSS
PHP
SQL

I'm also familiar with (but don't know in full):
C
C++
Java
VB6
VB.NET

I'd like to know C++ in full or maybe Java.

Lorem-Ipsum
22-09-10, 22:29
Java has become very bloated. Python is starting to replace it in a lot of places.

Faz
22-09-10, 23:32
Do a cheeky bubblesort with a mid(stringname(1,1)) to check the first letter and order alphabetically. Very bloated but extremely fun!

Lorem-Ipsum
22-09-10, 23:42
Do a cheeky bubblesort with a mid(stringname(1,1)) to check the first letter and order alphabetically. Very bloated but extremely fun!

I found that method when I was looking into it. It didn't look very fun to me XD.

Faz
23-09-10, 14:49
haha, it would be satisfying, but as I say, too bloated for it to really work. And quite slow. There must be a function that sorts a listbox... try the help? We did 2 lessons on how to use the help - it's so hard!

p.s. it is .net yes?

Lorem-Ipsum
23-09-10, 17:25
AS I want to run it when I add a new item I put it in the listbox sub. It runs along the lines of:


listBox1.Sorted = True

Already found it mate.^^^^^

I may do your method just for fun. Would give me a wee bit of experience too.

Faz
23-09-10, 20:56
I hated bubblesort, couldn't understand it. Good tutorial on youtube if you get stuck, though.