Welcome to Dream.In.Code
Become a VB Expert!

Join 137,271 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,453 people online right now. Registration is fast and FREE... Join Now!




Textbox sorting

 
Reply to this topicStart new topic

Textbox sorting, Sorting a textbox into alphabetical order or making a listbox an outpu

OutlanderSE
12 Dec, 2006 - 03:24 AM
Post #1

New D.I.C Head
*

Joined: 12 Dec, 2006
Posts: 4


My Contributions
hey i am quite new to VB and i am doing a project at school where i need to make a grade calculator.
i have got so far fine but i am now stuck with the final taks... sorting the grades into order. there are two ways i can see of doing this with my code (mostly if statements and strings) 1 is to somehow make the output textbox sort its values into alphabetical order or 2 making a listbox the output box with sorting enabled. if anyone can tell me how to do either these or something else then it would be most appreciated. and im new to vb so try to keep the code simple for me biggrin.gif cheers Outty
User is offlineProfile CardPM
+Quote Post

Hacker
RE: Textbox Sorting
12 Dec, 2006 - 07:53 AM
Post #2

New D.I.C Head
*

Joined: 10 Dec, 2006
Posts: 3


My Contributions
QUOTE(OutlanderSE @ 12 Dec, 2006 - 04:24 AM) *

hey i am quite new to VB and i am doing a project at school where i need to make a grade calculator.
i have got so far fine but i am now stuck with the final taks... sorting the grades into order. there are two ways i can see of doing this with my code (mostly if statements and strings) 1 is to somehow make the output textbox sort its values into alphabetical order or 2 making a listbox the output box with sorting enabled. if anyone can tell me how to do either these or something else then it would be most appreciated. and im new to vb so try to keep the code simple for me biggrin.gif cheers Outty

copy the content of the list box one by one and compare if less add it before and if greter than add after
User is offlineProfile CardPM
+Quote Post

OutlanderSE
RE: Textbox Sorting
12 Dec, 2006 - 09:16 AM
Post #3

New D.I.C Head
*

Joined: 12 Dec, 2006
Posts: 4


My Contributions
well what my program does is the user is prompted to enter a subject and a score then it calculates the score turning it into a grade (all on form1) on form 2 i want it to take the converted grade (stored as a string) and print them into the listbox.
User is offlineProfile CardPM
+Quote Post

Mach1Guy
RE: Textbox Sorting
12 Dec, 2006 - 12:25 PM
Post #4

D.I.C Head
Group Icon

Joined: 4 Dec, 2006
Posts: 79



Thanked: 4 times
Dream Kudos: 25
My Contributions
will setting the box property to Sorting enabled not work for what you want?
User is offlineProfile CardPM
+Quote Post

OutlanderSE
RE: Textbox Sorting
12 Dec, 2006 - 03:13 PM
Post #5

New D.I.C Head
*

Joined: 12 Dec, 2006
Posts: 4


My Contributions
yeah but i dont know how to make the strings appear in the list box for example previously i hade a textbox and use
CODE

Form1

Dim I as string = textbox1.text
Dim S as String = Textbox2.text
Dim U as string
U = "Grade U"
If I <39 then
Form2.Textbox1.appendtext (S & U)

that ment that when the button was pressed it would show the strings in the textbox but when i replace Form2.textbox1.appendtext with Form2.listbox then appendtext doesnt register and i cant find a replacement line of code.

This post has been edited by OutlanderSE: 12 Dec, 2006 - 03:14 PM
User is offlineProfile CardPM
+Quote Post

Mach1Guy
RE: Textbox Sorting
13 Dec, 2006 - 06:01 AM
Post #6

D.I.C Head
Group Icon

Joined: 4 Dec, 2006
Posts: 79



Thanked: 4 times
Dream Kudos: 25
My Contributions
I believe in order to use a list of this sort it is best to use a listbox instead of a textbox. With a listbox you can add items by using lstGrades.Items.Add(txtGrade.Text)
Also make sure to set the Sorted = True for the listbox so that each item you add will automatically be sorted. There are many more properties and methods that listboxes have that can simplify things. Let me know if this is what you need.

This post has been edited by Mach1Guy: 13 Dec, 2006 - 06:02 AM
User is offlineProfile CardPM
+Quote Post

OutlanderSE
RE: Textbox Sorting
13 Dec, 2006 - 09:04 AM
Post #7

New D.I.C Head
*

Joined: 12 Dec, 2006
Posts: 4


My Contributions
thats exactly what i needed its all working now
cheers
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 07:59PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month