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.. ^_^

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.