Ask Visual Basic Expert

Objectives

At the end of this lab you should be able to:

- Learn how to open and close external (data) files.
- Use File Dialog boxes to locate files.
- Read data from input files and write data to output files (sequential data files)
- Understand the concept of fields and records in sequential files
- Read an entire line from a file (a record) and then breakdown into required fields.
- Use loops to read contents of data files.
- Use Try/catch blocks to handle file input/output errors.

Activity 1: An application to analyze Exam Results using files and arrays

Example: Figure below shows the contents of the file, marks.txt.

553_marks.png

Create an Open menu item under File menu item and program the following requirements under its click event handler.

- Use a FileOpenDialog dialog box to locate and get the file path for marks.txt (you can create this file using Notepad or Notepad++ and save it in you USB drive or to any other appropriate directory)

- Once file is selected, open it and using a loop read the entire contents of the file line by line, extracting name and mark and storing them in the names and midterm marks array.

You application will still require the following array (declared at either module/class level or procedure level - you have to decide), however without the initialization and size is set at 10.

Dim strNames(9) As String
Dim dblMarks(9) As Double

The rest of the program remains the same using a command button or a menu item that when clicked produces the following statistics as before, such as:

- Average mark
- Highest mark scored and the student who scored it. (* There are no ties)
- Lowest mark scored and the student who scored it (** There are no ties)
- The range (i.e. Highest score - lowest score)

Display the results appropriate labels on your form.

Activity 2: Investment application (writing results to a file)

Modify the Investment application so that it does the following:

Have a command button or menu item called "Print to File" (that the user can click after clicking the "Calculate" button or menu item) and under its click event handler:

- Use a FileSaveDialog dialog box to choose a location to save the contents of the results in the list box.

- Once the save to directory and filename (say Investment.txt) is chosen, open it and write the contents of the textboxes [initial investment amount, the percentage return on investment over the year and the number of years of the investment (duration)] each on a separate line. Then using a loop write the entire contents of the list box with each value on a separate line.

- The format of how the file contents should appear is given below:

Investment.txt - content

Initial investment: value of textbox for initial investment

% return on investment: value of textbox for % return

Investment period: value of textbox for duration

Year 1: first item in list box
Year 2: second item in list box
Year 3: third item in list box
:
:
:
Year N: last item in list box

Visual Basic, Programming

  • Category:- Visual Basic
  • Reference No.:- M91307297
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Visual Basic

Please show how to do the belowvisual basic net application

Please show how to do the below: Visual Basic .NET Application - Coding Exercise 1 (Exercise 13, Zak, 2016, p. 347) For this coding exercise, write the Visual Basic code for a pretest loop that uses an Integer variable n ...

Assignment virtual storeuse the concepts and scenario from

Assignment: Virtual Store Use the concepts and scenario from Assignment 1 to help "Your" Virtual Business to increase the functionality of its online shopping cart. When a customer checks out, the shopping cart must stor ...

Assignment frans virtual fruit standfrans virtual fruit

Assignment: Fran's Virtual Fruit Stand Fran's Virtual Fruit Stand is an online store that sells several types of dried fruit. Based on the needs of Fran's Virtual Fruit stand, you must design a flowchart using Visual Log ...

Pitch amp game design documentthe assignment is about

Pitch & Game Design Document The assignment is about educational driver for teenagers Assignment Brief: In groups you will: - present a pitch and produce a one sheet - provide a demonstration of your game - produce a hig ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As