Results 1 to 8 of 8

Thread: Anyone want a challenge?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Anyone want a challenge?

    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.
    Attached Files Attached Files

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Anyone want a challenge?

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: Anyone want a challenge?

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Anyone want a challenge?

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: Anyone want a challenge?

    Shows how much i know huh? Like i said it only displays phoenix over and over, and should display the whole row, and not just phoenix.
    Heres the code:

    If radDepartureCity.Checked Then

    gstrNames(0) = "New york"
    gstrNames(1) = "Chicago"
    gstrNames(2) = "Houston"
    gstrNames(3) = "Cincinnati"
    gstrNames(4) = "Albany"
    gstrNames(5) = "Phoenix"

    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

    End If

    End Sub

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Anyone want a challenge?

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: Anyone want a challenge?

    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.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Anyone want a challenge?

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width