Textbox sorting

Sorting a textbox into alphabetical order or making a listbox an outpu

Page 1 of 1

6 Replies - 9149 Views - Last Post: 13 December 2006 - 10:04 AM Rate Topic: -----

#1 OutlanderSE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-December 06

Textbox sorting

Posted 12 December 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 :D cheers Outty

Is This A Good Question/Topic? 0
  • +

Replies To: Textbox sorting

#2 Hacker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 06

Re: Textbox sorting

Posted 12 December 2006 - 08:53 AM

View PostOutlanderSE, on 12 Dec, 2006 - 04:24 AM, said:

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 :D 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
Was This Post Helpful? 0
  • +
  • -

#3 OutlanderSE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-December 06

Re: Textbox sorting

Posted 12 December 2006 - 10:16 AM

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.
Was This Post Helpful? 0
  • +
  • -

#4 Mach1Guy  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 89
  • Joined: 04-December 06

Re: Textbox sorting

Posted 12 December 2006 - 01:25 PM

will setting the box property to Sorting enabled not work for what you want?
Was This Post Helpful? 0
  • +
  • -

#5 OutlanderSE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-December 06

Re: Textbox sorting

Posted 12 December 2006 - 04:13 PM

yeah but i dont know how to make the strings appear in the list box for example previously i hade a textbox and use
 
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 December 2006 - 04:14 PM

Was This Post Helpful? 0
  • +
  • -

#6 Mach1Guy  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 89
  • Joined: 04-December 06

Re: Textbox sorting

Posted 13 December 2006 - 07:01 AM

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 December 2006 - 07:02 AM

Was This Post Helpful? 0
  • +
  • -

#7 OutlanderSE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-December 06

Re: Textbox sorting

Posted 13 December 2006 - 10:04 AM

thats exactly what i needed its all working now
cheers
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1