Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions In this case, you will create a Visual Basic solution that displays the Galaxy Trekkers club membership. This program uses an array of structures

image text in transcribed

Instructions

In this case, you will create a Visual Basic solution that displays the Galaxy Trekkers club membership. This program uses an array of structures to hold membership information that is read in from a sequential file. You will use a graphic file and a text data file with the instructions below.

Step 1: Create the Project:

Create a Visual Basic Project using the project name GalaxyTrekkers.

Step 2 Design the Form:

Design the form as shown in Figure 1. You will need one button control, one list box, and one picture box. Load the downloaded galaxy.jpg image into the picture box.

Step 3 Add the text file to the project:

Copy the downloaded text file to the GalaxyTrekkers folder using Windows Explorer. In the VB.Net IDE, click on the Project menu and select Add existing item. Browse to the GalaxyTrekkers folder. In the File Type combo at the bottom of the Add Existing dialog, select All Files. You will now see the downloaded file StudentList.txt. Select it and click on Add. The text file will now appear in the Solution Explorer. By doing this, you are now able to view the contents of the file within the IDE by double-clicking its name in Solution Explorer.

Look at the file contents. You will see that there are 6 fields for each record, separated by commas. The fields are ID, last name, first name, middle initial, grade, and class period. These fields will need to be declared as member variables in a structure. Treat all of these fields as type String.

Step 4 Declare the form-level variables:

Declare a structure named Members that contains a member variable for each of the fields in the text file.

Declare an array of type Member with a size of 250.

Step 5 Write a procedure to read the text file and load the list box:

Chapter 11 presented introduction (split function) that read the entire contents of a text file into memory and then parsed out each record by searching for the occurrence of a delimiter. In this program, you will do that, but after reading in one line of the text file, you must also break out the individual fields.

For each line in the text file, create a new structure of type Member, and load the individual member variables of the structure with the values from the text file line. Then add that structure to the next available position in the array of structures.

When the entire file has been read in and loaded into structures in the array, then load the list box by reading the array. Only the ID, last name and first name fields will be loaded into the list box. See Figure 2 for details of how the list box contents should appear.

Hints:

1 Use a For loop to break out the fields in each line of the text file, because you know how many fields there are.

2 You will have to pad the ID field to a length of 10 to make the display in the list box look right.

Step 6 Add code in the Forms Load event:

Call the procedure created in Step 5 to load the data into the structure array and display the members in the list box.

Step 7 Finish up:

Be sure to add the code for the Exit button.

Step 8: Save and run

Save all files, then start the application. Figure 2 shows a sample run of this program

image text in transcribed

Galaxy Trekkers Membership Galaxy Trekkers membersListBox Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions