Results 1 to 15 of 15

Thread: Girl in trouble - heeelp :)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2020
    Posts
    2

    Girl in trouble - heeelp :)

    I have a txt file with 3 columns.

    1st column: cityid1

    2nd column: cityid2

    3rd column: distance between cityid1 and cityid2

    My question is... How I can read that data from txt file, have one dropdown list (choose 1st city), then based on that dropdown, choose second dropdown list (choose a city), and then get the distance as the final result.1.txt

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Girl in trouble - heeelp :)

    Probably use ReadAllLines as a starting point. That would bring all the lines from the text file into an array of strings. The next step would be to split each line into the three columns and do something with them. However, exactly what you would do depends on several factors. You might use String.Split to split each row into the different columns, but that would just result in a list of strings. The first element would be cityid1, the second element would be cityid2, while the third would be the distance. If that file has the distance between X and Y for every combination of cityid1 and cityid2, then you would find MANY rows with cityid1 being X. One for each cityid (though maybe the distance between cityid1 and itself will have been left out).

    So, you'd then want to go through the set of rows and get all the unique cities, since that's what you'd want to be showing in each of the listboxes. You'd also want to be able to use two cities to lookup a distance. There are several ways that could be done. The weirdest would be a Dictionary (of String, integer), but that's a solution that is so unlikely to be ideal that I hesitate to mention it. If the file has both {X, Y, distance} and {Y, X, distance}, then that dictionary could be oddly efficient, but if you only have {X, Y, distance}, and not {Y, X, distance}, which seems more likely, then the dictionary wouldn't work.

    So what's the alternative? Kind of depends on what you've covered in class. Making a custom class would probably be best, but if you haven't covered that, then what have you done? Most likely, there is a technique you are expected to use.
    My usual boring signature: Nothing

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Girl in trouble - heeelp :)

    Homework, anyone? You have described a multi-stage process and asked us how to do every stage, with no indication that you've made any effort at all. There are plenty of people here willing and even eager to help, but we're not just code-writing machines. You should be doing what every developer should be doing on every problem, i.e. breaking it down into its constituent parts, researching each part individually, doing the parts they can for themselves and then asking specific questions about the other parts. Furthermore, you should be working out the steps you'd perform if you were doing the job manually, turning those steps into a more formal algorithm and then writing code to implement that algorithm specifically. Taking the assignment as a single until and expecting to dump all the code in one god with no actual thought about the problem is not programming. The first step is reading the file, which has nothing specifically to do with any of the rest of it so can be addressed independently of the rest. My gift to you is the information that you should use a TextFieldParser to read a delimited or fixed-width column text file. Now you have a direction for your research.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2020
    Posts
    2

    Re: Girl in trouble - heeelp :)

    I believe that you can do it in less than 30 minutes...

    OK...Let's make a bet then...

    You help me with this, and I'll learn it,books, yt videos, whatever, and do my best to help other people here also...

    It really makes me mad that I can't do it, so I'll do my best to keep my word...

    OK?

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Girl in trouble - heeelp :)


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

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by .paul. View Post
    It doesn't sound like there's any sort of calculation to be done. That the value represents a distance seems somewhat arbitrary. The exercise here seems to be just a lookup based on a compound key. What it is that's being looked up isn't really relevant.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Girl in trouble - heeelp :)

    The download link is down there as a result of the MSDN Gallery closure, so here it is...

    Distances_-_As_the_crow_flies.zip

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

    Re: Girl in trouble - heeelp :)

    Also, for future reference, could you please provide a title for your threads that summarise the issue described in the initial post? Titles like this one are as good as no title at all as they don't provide any indication of whether opening the thread will be worthwhile or a waste of time. We should have a fair idea of what we're going to see in the thread from the title alone. Everyone who posts needs help so the word "Help" is of no value. That you're a girl isn't really relevant and if the trouble is a programming issue then it would be a concern if you were posting here when you weren't in trouble. Just the facts, ma'am.

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by jmcilhinney View Post
    It doesn't sound like there's any sort of calculation to be done. That the value represents a distance seems somewhat arbitrary. The exercise here seems to be just a lookup based on a compound key. What it is that's being looked up isn't really relevant.
    Ahh right... i obviously didn't open 1.txt until now. Might help someone else

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by jmcilhinney View Post
    Homework, anyone? You have described a multi-stage process and asked us how to do every stage, with no indication that you've made any effort at all. There are plenty of people here willing and even eager to help, but we're not just code-writing machines. You should be doing what every developer should be doing on every problem, i.e. breaking it down into its constituent parts, researching each part individually, doing the parts they can for themselves and then asking specific questions about the other parts. Furthermore, you should be working out the steps you'd perform if you were doing the job manually, turning those steps into a more formal algorithm and then writing code to implement that algorithm specifically. Taking the assignment as a single until and expecting to dump all the code in one god with no actual thought about the problem is not programming. The first step is reading the file, which has nothing specifically to do with any of the rest of it so can be addressed independently of the rest. My gift to you is the information that you should use a TextFieldParser to read a delimited or fixed-width column text file. Now you have a direction for your research.
    In the absence of any confirmation or denial, i'll forgive the spelling mistakes. Those steps you describe - we more or less all use them, but most of us don't consciously work through a tick list. What i use is a form of programming known as extreme... Google it.

    EDIT: The tick list is a good option for beginners though...

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by .paul. View Post
    The tick list is a good option for beginners though...
    Indeed. That was my point. Once you know the rules, you know when it's OK to break them. The more complex the problem, the more important the rules are. When you're a beginner, all problems are complex.

  12. #12
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by sarah17 View Post
    I believe that you can do it in less than 30 minutes...
    I think I am out of the competition, it will take me a few hour to do it
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by sarah17 View Post
    You help me with this
    No one is suggesting not helping but doing it for you is not just helping. Do the research now, not after we do your homework for you. Have you researched the TextFieldParser class yet? I'm guessing not. In my experience, it's not that people can't do things. It's that they don't want to approach them systematically because that seems to much like work. They just want to think of an idea and have a bunch of code appear. That's not how it works. If that's how you try to approach things then you'll never succeed because programming really depends on building solutions to problems on smaller solutions to smaller problems. If you're not prepared to first figure out what those smaller problems are, you'll never get anywhere.

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Girl in trouble - heeelp :)

    Quote Originally Posted by sarah17 View Post
    I believe that you can do it in less than 30 minutes...
    You're probably right but the fact that we can do it quickly doesn't mean that we should cheat for you. The point is for you to show what you've learned and to reinforce it by using it. If you can't do that then you don't deserve the marks for the assignment. If you have to go back and reread all your notes for the class or whatever then that's what you need to to. If it takes a couple of days, that's how long it takes. Like I said, everyone here is willing to help with problems but you haven't even encountered a problem yet.

  15. #15
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Girl in trouble - heeelp :)

    I believe that you can do it in less than 30 minutes...

    OK...Let's make a bet then...

    You help me with this, and I'll learn it,books, yt videos, whatever, and do my best to help other people here also...

    It really makes me mad that I can't do it, so I'll do my best to keep my word...

    OK?
    I find it very telling and somewhat interesting that you felt the need to let us know your gender. This isn't Twitch. There are no simps here that will bend over backwards for the pleasure of doing your homework for you just because you're a woman.

    If I'm wrong about you, I apologize but around here, people don't just do other people's homework especially if they showed no sign of having put any effort at all. If I'm right about you and you're just looking for someone to do all the work for you, well you're in luck. Simping culture is at an all time high all over the internet and I'm sure you can easily find a boat load of simps somewhere online to do this for you and even thank you for it(Don't ask my why though I will never understand simps).....you just won't find it here.
    Last edited by Niya; Jul 6th, 2020 at 08:02 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

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