473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

sorting

2
I don't know how to sort this one. Can you please help me?

Using array, and using the bubble sort...

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Public ctr As String
  3.  
  4. Private Sub cmdAdd_Click()
  5. Dim a As Integer
  6. Dim abc As String
  7.  
  8. a = InputBox("Number")
  9.  
  10. For a = 1 To a
  11.     abc = InputBox("name")
  12.     List1.AddItem abc
  13. Next a
  14.     cmdAdd.Enabled = False
  15.     ctr = a
  16.  
  17. End Sub
  18.  
  19. Private Sub cmdsort_Click()
  20.     Dim x As Integer
  21.     Dim y As Integer
  22.     Dim compare1 As String
  23.     Dim compare2 As String
  24.  
  25.     x = 0
  26.     y = 0
  27.  
  28.     compare2 = List1.List(y + 1)
  29.     compare1 = List1.List(y)
  30.  
  31.     While x <= ctr - 1
  32.         If x = ctr Then
  33.             List2.AddItem compare1
  34.         Else
  35.             If compare1 <= compare2 Then
  36.                 compare1 = compare1
  37.                 x = x + 1
  38.  
  39.             List2.AddItem compare1
  40.                 y = y + 1
  41.                 compare2 = List1.List(y + 1)
  42.                 compare1 = List1.List(y)
  43.             Else
  44.                 compare1 = compare2
  45.     End If
  46. End If
  47.  
  48. Wend
  49.  
  50.  
  51. End Sub
Sep 17 '07 #1
2 1014
hariharanmca
1,977 1GB
I think we have sort option in listBox itself!

Set Property Sorted = True in property window.
Sep 17 '07 #2
Killer42
8,435 Expert 8TB
As Hari pointed out, the ListBox control has a Sorted property which may solve your issue. The thing is, you haven't actually told us what the problem is.
Sep 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.