Programming Assignment #5

Search Functionality using LINQ

 

The file, “Colleges.txt” contains a list of colleges around the country.  Place this file in your bin/debug directory.  Update the file to include Your name college.  For example if your name is Robert Smith you would add Robert Smith College to the .txt file.  This must be included for your assignment to be accepted. 

 

In this assignment, you will create a Visual Basic program that reads the values from the Colleges text file, displays those colleges in a listbox, and allows the user to enter characters in a textbox to search for one or more colleges in the listbox and display the results in another listbox.  The number of colleges returned from the search is displayed in a textbox below the results.  The program also allows the user to sort the colleges listbox in ascending or descending order.  Finally, a clear button clears the results in the listbox, the search textbox, and the number of colleges returned from the search textbox.  A quit button is provided, which exits the application.

 

The figures below show the output of the Visual Basic program that performs the functionality described above.

 

Deliverables:

1.      Write a Visual Basic program that displays the information below and performs the functionality described above. 

2.      Using the IO.File.ReadAllLines method, read the contents of the colleges.txt file into an array.

3.      When the form loads, display the contents of the array in the Colleges listbox.

4.      When the user enters something in the Search Colleges textbox and presses the “Go” button, the program should search the array upon which the colleges listbox is displayed.  Use a LINQ query to do this.  Note that the user may type in a full college name as illustrated in Figure 1 below, or he may enter only part of the name (even one letter), and the listbox should be populated with all colleges that start with the same letter(s) as those entered by the user.  Figure 2 below illustrates the search for all colleges that begin with the letter “lib”. 

a.       Be sure to make your search NON-case sensitive.  That is, if the user enters “LiBERty UnIVERsiTy” in the textbox, it should still retrieve the college “Liberty University”. [Hint: If you convert the value that the user enters into uppercase and search for values that are converted to uppercase, this allows for a match to be found.]

b.      Using LINQ queries, write the code such that when the user clicks the Sort Ascending button, the colleges displayed in the Colleges listbox is sorted from A-Z.    Conversely, when the user clicks the Sort Descending button, the listbox should be sorted from Z-A.  Although this feature can be accomplished using the properties of the listbox, your code  should be written using LINQ queries to perform these functions

[Hint:  Before you set the datasource property of your listbox to the results of your LINQ query, you must first remove the datasource linkage to the original array by setting .datasource = nothing.]

5.      Using a certain property of listboxes, determine the number of search results displayed in the Results listbox and display that number in the textbox shown below the listbox.  Note:  Do NOT use a LINQ query for this task.

6.      Use appropriate software development guidelines, such as clearing the results listbox before populating it with new data when the Go button is clicked and including a title on the form.

7.      Your assignment should include internal communication and proper naming conventions. 

 

Figure 1:

 

 

 

Figure 2:

  • 11 years ago
Programming Assignment #5
NOT RATED

Purchase the answer to view it

blurred-text
  • attachment
    country_search.rar