In VB 2010 i have an extensive project im working on and cannot seem to figure it out anymore. I have the interface ready but can't get the buttons to sort correctly.
What i'm trying to get now is the sort button to sort the flights alphabetically or numerically depending on weather i click departure, arrival or flight number from the radio buttons, and i have NO CLUE how to add and delete lines into a listbox. I also need the itinerary at the bottom to list any combination of leaving from "insert city here" to arriving to "insert city here" for example, if i leave from cincinnati and need to get to new york, and theres a layover in chicago, it displays leaving from cincinnati, to chicago, leaving from chicago to new york, and only those available flights. Like i said, lost with no clue. Someone please plug all of this in and see if you can get it to work. I have attached the VB in zip file and attached the text file.
Thanks for any help.
Presumably this is coursework so I won't be writing any code for you and I'm not a big fan of downloading, extracting, opening and then trawling through someone else's project as a first option either. If you can provide some relevant information though, I can provide some direction, but let's handle one issue at a time, shall we? You should ask for help with one issue, resolve it and then start a new thread for the next issue.
With regards to your Buttons, you should just handle the Click event for each one and then, in each event handler, put If...EsleIf statements to determine which RadioButton is checked and then sort accordingly. How you sort depends on a couple of things. Firstly, how is your data stored? Is it in a DataTable, a list/array of objects or something else? Also, are you able to bind your data to the ListBox or do you have to add items manually?
I agree. It's a list array. If youll look at my code i have written out the process but it just repeats a word in the wrong column. It needs to rearrange the whole row alphabetically based on the radio button i clicked, departure city or arrival city gets alphabetized.
I haven't looked at your code and nor will I as a first option. To my mind, uploading entire should be a last resort. Your first option should be to include the relevant code right in your post, between [code][/code] or [highlight=vb.net][/highlight] tags. That way we can see the code we need to see without going anywhere or doing anything.
Also, there is no such thing as "a list array". There's an array, there's an ArrayList and there's a List(Of T) where T is whatever type you choose to use, but "a list array" doesn't actually mean anything specific.
Dim intpassNum As Integer, i As Integer, strTemp As String
For intpassNum = 0 To 4
For i = 0 To 4 - intpassNum
If gstrNames(i) > gstrNames(i + 1) Then
strTemp = gstrNames(i)
gstrNames(i) = gstrNames(i + 1)
gstrNames(i + 1) = strTemp
End If
Next i
Next intpassNum
It looks like you have multiple arrays. The code you have is just going to sort the departure city names without keeping the related data for each flight in the same order. Is that going to be OK? It seems that you are not maintaining the relationships among the three separate data items for each flight at all.
Right. I need to keep the whole line of text their: flight number, departure city, time, arrival city, time, fare, etc. and it just keeps displaying phoenix i have no idea what im doing.
If you need to keep all the data for a flight together then just sorting the names is no good to you. Even if it sorts correctly, the names will be in the correct order but nothing else will be and you'll have lost the relationship between each name and the rest of the data that it is associated with. Can you see that? Have you been told to use separate arrays for each field?