Results 1 to 5 of 5

Thread: Hashtable for my Distance Finder Program

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    7

    Hashtable for my Distance Finder Program

    Hey all i need help with the following code. Ive set up a Hashtable but it seems to have errors, i've never done one of these before. Here is some of my code as an example:

    private Hashtable _distances;

    _distances=new Hashtable();

    Hashtable birminghamDistances=new Hashtable();
    birminghamDistances.Add("Birmingham",0);
    birminghamDistances.Add("Cardiff",103);
    ...
    _distances.Add("Birmingham",birminghamDistances);

    Hashtable distanceForSelectedTown = (Hashtable)_distances[txtFromTown.Text];
    int distance=(int)distanceForSelectedTown[txtToTown.Text];
    txtDistance.Text=distance.ToString();

    I'm getting errors on line 1 (private Hastable), line 3 (_distances), line 5 (new Hashtable), line 9 (_distances) and line 11 (distances[txtFromTown.Text]

    What im trying to make is this:

    http://www.wrestlefury.com/distancefinder.jpg

    When two places are entered in the textboxes and the calculate distance button is pressed, i want the distance to show up in the Distance Textbox. But i cant do this Hashtable, could someone please help?

    Regards,

    Rob

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: Hashtable for my Distance Finder Program

    What are the errors? Are you including the System.Collections namspace?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    7

    Re: Hashtable for my Distance Finder Program

    no whats that? Ive put in brackets what the errors are. Im putting this hashtable is under btnDistance.

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: Hashtable for my Distance Finder Program

    If your getting an error like
    "the type or namespace name 'Hashtable' could not be found
    add
    using System.Collection;
    to the start of your project.

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    7

    Re: Hashtable for my Distance Finder Program

    Ive done that it still has errors, there must be something wrong with my code.

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