Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

VISUAL BASIC: Write a program that reads in the text file \"names.txt\" provided

ID: 3813028 • Letter: V

Question

VISUAL BASIC: Write a program that reads in the text file "names.txt" provided in the assignment folder in blackboard. You are allowed to use a fixed size array for this project. Assume a maximum file size of 100 entries. Make sure you count how many you retrieve from the file! Your program should then display all of the names, in the provided order, in a list box on the left hand side of the form. You should then create two buttons on your form. One button will sort the list into ascending order, the other descending order. You may use any sort algorithm that you want though I would suggest the Bubble Sort is easiest to code. The result of the sort should then be displayed in a separate list box on the right hand side of the form. Something similar to the following: NOTE: You must write your own SORT routine. You are not allowed to use the internal Visual Basic Sort functions. In Visual Basic, if you simply specify the filename in the IO.File.OpenText() function call, then VB will expect the file to reside in the binDebug subdirectory where you are storing your source code. in my case the file is actually stored in: D:Trent_Teachingj0h_VBVB_ProjectsAssignment_4File_Sort_Assig nment4File_Sort_Assignment4inDebug Should you have difficulty placing the data file there, you are allowed to specify a complete path to the filename in the function call. As an example if I am developing my application in the folder D:Trent_Teachingj0h_VBVB_ProjectsAssignment_4, I could place the names.txt file in that directory. I would then change the function call to be: IO.File.OpenText("D:Trent_Teachingj0h_VBVB_ProjectsAssignment_4 ames.txt")

names.txt includes the following names

File Sort File Content Edwin Hubble Robert Oppenheimer Jonas Salk Richard Feymman James Watson Carl Sagan Annie Jump Cannon Henrietta Leavitt Dian Fossey Barbara Mcantock Grace Hopper Maria Mitchell Al-Zahrawi Al-Zarqali Ibn al-Shatir Al-Khalili al Jazari Al-Idrisi Ruby Payne-Scott Gregor Mendel Erwin Schrodinger Lise Meitner Isaac Newton Michael Faraday Charles Babbage Charles Darwin Read in names bd Ascending Order Descending Order Sorted Output Exit

Explanation / Answer

namespace WindowsFormsApplication4 { public partial class Form1 : Form { add myadd = new add(); public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { myadd.data(textBox1.Text); label1.Text = myadd.count.ToString(); } namespace WindowsFormsApplication4 { class add { string[] mydata = new string[10]; int mpointer = 0; public int count { get { return mpointer; } } public void data(string input) { if (mpointer Convert.ToInt32(n)).ToArray(); int temp=0; for (int j = 0; j