0

somebody help me...

im using VB6.0 for my project and badly i need a littlE help,,

the program should goes like this:
--==>>>when yOu input a number in a textbox and

click a command button label with"ADD" the number you input will automatically add to the listbox but should be in ascending order..

is this right??? in listbox properties i set the "sorted=true" but the output goes like this:

1
11
14
2
22
3

what am I expecting is like this:

1
2
3
11
14
22

-----------====>>>help....... ill wait for a reply.. ^_^

3
Contributors
2
Replies
12
Views
7 Years
Discussion Span
Last Post by vb5prgrmr
0

Hi
Here is my simple help.
If you are using only numbers in TextBox then use below code.

Private Sub Command1_Click
Dim strItem As Integer
strItem = Text1.Text
List1.AddItem strItem
End Sub

Remember to Set Sorted=True in Listbox Properties as you have set.
Hope this Helps.

Thanks

0

Yes, that is the expected output of the listbox when sorted is set to true. Now, there are a couple of ways in which to get around that...

One is to do the sorting yourself and with a search for vb6 sorting routines with your friends (yahoo, google, ask, answers, bing) you should be able to find some code out there like this most excellent tutorial... http://www.vbforums.com/showthread.php?t=473677 This of course is with the sorted property set to false.

The other way is to make all your strings the same length by using the format function... Format(Text1.Text, "0000")...

Good Luck

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.