-
Jun 28th, 2020, 08:07 PM
#1
Thread Starter
New Member
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
-
Jun 28th, 2020, 08:25 PM
#2
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
-
Jun 28th, 2020, 08:28 PM
#3
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.
-
Jun 28th, 2020, 09:09 PM
#4
Thread Starter
New Member
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?
-
Jun 28th, 2020, 09:19 PM
#5
Re: Girl in trouble - heeelp :)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 28th, 2020, 09:24 PM
#6
Re: Girl in trouble - heeelp :)
Originally Posted by .paul.
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.
-
Jun 28th, 2020, 09:26 PM
#7
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 28th, 2020, 09:28 PM
#8
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.
-
Jun 28th, 2020, 09:29 PM
#9
Re: Girl in trouble - heeelp :)
Originally Posted by jmcilhinney
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 28th, 2020, 09:38 PM
#10
Re: Girl in trouble - heeelp :)
Originally Posted by jmcilhinney
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...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 28th, 2020, 10:28 PM
#11
Re: Girl in trouble - heeelp :)
Originally Posted by .paul.
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.
-
Jun 29th, 2020, 04:28 AM
#12
Re: Girl in trouble - heeelp :)
Originally Posted by sarah17
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)
-
Jun 29th, 2020, 04:50 AM
#13
Re: Girl in trouble - heeelp :)
Originally Posted by sarah17
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.
-
Jun 29th, 2020, 04:53 AM
#14
Re: Girl in trouble - heeelp :)
Originally Posted by sarah17
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.
-
Jul 6th, 2020, 07:51 PM
#15
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|