Ask Visual Basic Expert

In this solution, you will create a Class Library project that will count the number of characters, words, sentences, and paragraphs contained in a text file or a multi-line text box.

You will also create a Windows Application to test the Class Library project you create. The Class Library project will have one class module. The class will have one method that will open a text file for input.

The same method should also count the number of characters, words, sentences, and paragraphs in the file. Another method will perform the same task but use a multi-line text box. The developer should be able to read these values using read-only properties.

The form will have an OpenFileDialog control instance to open a file as specified by the user. Figure (1) shows the completed form.

- Start VB .NET, and then create a new Windows Application project. Name the solution mech_Unit5.sln.

- Add a Class Library project to the solution. Note that VB .NET will create an empty class mod- tile. Name the Class Library project Unit5ClassLibrary.

- Set the name of the class automatically created by VB .NET to StringProcessor.

- Set the root namespace to Course.

- In the Windows Application project add a reference to the Class Library project.

- In the class module, declare hidden variables to store the number of characters, words, sentences, and paragraphs.

- Create four read-only properties named Characters, Words, Sentences, and Paragraphs. These properties should return the number of characters, words, sentences, and paragraphs, respectively, stored in the corresponding hidden variables. Create Property Procedures rather than Public variables.

- Create a read-write property named StringContents, and a hidden variable to store the string. If the developer sets the property, calculate the number of characters, words, sentences, and paragraphs contained in the string, and then store the results in the hidden variables that you declared. Note: A word is a sequence of characters separated by a space. A sentence is terminated with a period, and a paragraph ends with a LineFeed character (Microsoft.VisualBasic.ControlChars.Lf). Your solution does not need to account for malformed sentences. For example, a paragraph that ends in something other than a sentence with a period.

- In the class module, create a method named OpenFile. This method should accept one argument - the full path name of the file to be opened. In the OpenFile method, write the necessary statements to open the text file, then count the number of characters, words, sentences, and paragraphs. As you will he reading a disk file, you will need to rise the StreamReader class to open and read the file.

-The process of determining what constitutes a word can be expanded. For example, in addition to having a space character separate a word, tab characters should also separate words. Add this feature to the OpenFile method and the StringContents property procedure.

- Create the control instances on the form as shown in the Figure.

- Write the code for the Analyze Text button. The code in this event handler should create an instance of the StringProcessor class. Set the StringContents property to the contents of the multiline text box. Assigning a value to the property causes the code you wrote in the Property Procedure to process the string, and set the values of the read-only properties. Store the value

of the Characters, Words, Sentences, and Paragraphs properties in the output labels appearing on the form.

-Write the code for the Analyze File button. Use the OpenFileDialog control instance to get a file name from the user. Create an instance of the StringProcessor class. Call the OpenFile method to process the file. Finally, display the results from theread-only properties in the labels on the form.

Enhancements cannot replace required functionality and they must be more significant than changing the color of the form or the font of a control. Significant enhancements are primarily code-based as opposed to using the Properties Window.

Suggestions for enhancing this projects are: creating a procedure to loop through a String and count the number of characters, words, sentences and paragraphs and calling that procedure when required; creating a procedure to display the calculated values in the appropriate controls on the Form and calling that procedure when required; displaying the text of a file in the TextBox control AFTER the file has been processed; adding a Label control that shows the path to the file being processed.

Please note that these are only suggestions and are not requirements. You are free to use your imagination to enhance the application. Two significant enhancements are required.

The Form is already created and the class has also been created. It is attached bellow named "mech_Unit5.sln".

Attachment:- mech_Unit5.sln.zip

349_p.png

Visual Basic, Programming

  • Category:- Visual Basic
  • Reference No.:- M91605932
  • Price:- $20

Priced at Now at $20, Verified Solution

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