I have posted items on my vb problem with detailes of my code to sort in vb with very little response, so i will be brief and present only my problem.
The only practical advice I got was to search for arrays and sorting through search engines. Several of them described how to sort numbers in an array, but nothing that showed how to carry names attached to numbers.

What I am trying to do is sort names attached to scores I have allocated and put them into a ListBox or TextBox or whatever in order best score top to bottom. I am using a bubblesort and list box at the moment, and get the names and numbers OK into the list box, but not sorted in order, i.e. I enter for example

Bill 145, which appears in the list box, then
joe 133 then
mike 150 and hope for a sort into

mike 150
bill 145
joe 133

Also when I type NameBox.Text it is accepted by VB But BestHcapBox. Text is not accepted but I am directed to the choice BestHcapBox.Count

This did not happen when I used similar code successfully 18 months ago, before I changed my pc and lost copies of the exact code.

I have had several readers of my post on other sites, but only one positive response. Can my English be that bad?

Many thanks for your speedy reply Comatose.

I am astonished at the time and thought that you and other interested parties expended in the thread you pointed me to.

You helped an 18 year old then. I am a pensioner with many interests, and the struggles to gain exam results are far behind me. I am not skilled in visual basic, and though I found your recommended thread fascinating, and followed your expansion reasonably well, I do not feel confident enough to try to adapt it for my purposes.

I give below code, if it merits that title, which I adapted from some given to me by a work colleague who has moved.
Something very much like it worked well enough for my purposes, but I lost the code when I bought a new pc.

If you care to look through it perhaps the fault which evades me will be obvious to you. As you can guess, it is an attempt to put race horses in top down order with scores I have accorded them.

One unusual change from my original now lost little program is that when I use NameBox.Text anywhere it is accepted,but if I try BestHcapBox.Text I am directed to BestHcapBox.Count. I am certain this did not happen in my original program.

Below I show what I am trying to do and the code as near as I remember which worked.

I should like to sort names and scores into top score to bottom, i.e. fred 130, joe 124, bill 143, max 119 and so on

into
bill 143
fred 130
joe 124
max 119

in a visual basic application, so need a bubblesort or other method to present name and score together.
My attempt at the moment is as follows. The name and score appear together in my ListBox, but not in best score, with name, in top to bottom fashion.

'now sort horses and scores in order

htotal(ct) = Val(TotBox.Text)

If ct = 0 Then

For Num = 0 To ct

For lefhorse = 0 To ct - 1

righorse = lefhorse + 1

righorse = lefhorse + 1

If htotal(lefhorse) < htotal(righorse) Then
temptot = htotal(lefhorse)
htotal(lefhorse) = htotal(righorse)
htotal(righorse) = temptot
bname = hname(lefhorse)
hname(lefhorse) = hname(righorse)
hname(righorse) = bname
End If

Next lefhorse

Next Num

ListBox.Clear '(I have forgotten where this was placed in the code)

For Num = 0 To ct
ListBox.AddItem Str(htotal(Num)) + " " + hname(Num)
Next Num

Else

ListBox.AddItem Str(htotal(ct)) + " " + hname(ct)

End If

ct = ct + 1

'ask if any more horses to enter

If ct >= 12 Then

MsgBox ("you have entered maximum number of runners")

End If

If it's not too big of a hassle, could you attach the project in a zip file to your next post?

If it's not too big of a hassle, could you attach the project in a zip file to your next post?

Apologies, Comatose

It is April since you asked me to send my project to you. I tried several times, and as you did not reply I feel sure I failed to use the zip properly. I gave up in despondency, not due to bad manners. I am not sure how to send my user face, but can send my code if you are still willing to help. I have really got no further despite many attempts, and hate to give up after the time I have spent on it.

I also tried recently to send a message in private to you more than once, but the content was neither saved nor delivered as far as I could see.

Hoping for a favourable reply

Bogeybrown

When you make a VB project, it has a bunch of files with it. So, in order to make sure we do this right.... make a new folder (on the desktop for simplicity), open the project in VB, click the file menu, click "save as", and change the folder list in that new window to the new folder you made, and click ok, or save, or whatever the button is.... once you save the project (it should save all the files with it) in the new folder, close out of VB, and find the new folder. Right Click on it, and choose "send to", and then click "Compressed (Zipped) Folder". It will make a file with the same name as the folder, but it will kinda look like a vice (this is assuming that you have windows XP). Attach that to the post.

When you make a VB project, it has a bunch of files with it. So, in order to make sure we do this right.... make a new folder (on the desktop for simplicity), open the project in VB, click the file menu, click "save as", and change the folder list in that new window to the new folder you made, and click ok, or save, or whatever the button is.... once you save the project (it should save all the files with it) in the new folder, close out of VB, and find the new folder. Right Click on it, and choose "send to", and then click "Compressed (Zipped) Folder". It will make a file with the same name as the folder, but it will kinda look like a vice (this is assuming that you have windows XP). Attach that to the post.

Dear Comatose

Yes I do use XP, the Home version

Failure looms over me. In trying to zip my project to you, I changed the name of my program and somehow lost it in more ways than one.

Now all I get is 'file not found - startup form or sub-main() required.' It seems I am a beginner self-taught badly, and too old to take up this fascinating visual basic as one of my hobbies.

Must I start all over again?

Yours,

Bogeybrown

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.