Question

In: Computer Science

Must be in Visual C# using windows forms : Create an application that opens a specified...

Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.

Solutions

Expert Solution

code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;

namespace UniqueWordsForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)
{
string txt = File.ReadAllText("doc.txt");
string[] arr = txt.Split(' ');
string[] res = UniqueWords(arr);
listBox1.DataSource = res;
}

public static string[] UniqueWords(string[] input)
{
if (input == null)
return new string[0];
else
{
ArrayList arr = new ArrayList();
for (int i = 0; i < input.Length; i++)
if (!arr.Contains(input[i]))
arr.Add(input[i]);
return (string[])arr.ToArray("".GetType());
}
}
}
}

Design:

namespace UniqueWordsForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(84, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Unique words";
//
// button1
//
this.button1.Location = new System.Drawing.Point(340, 144);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(107, 53);
this.button1.TabIndex = 3;
this.button1.Text = "Process file";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(87, 144);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 173);
this.listBox1.TabIndex = 4;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(538, 375);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "te";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1;
}
}


Related Solutions

***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class named PersonEntry. The PersonEntry class should have properties for a person’s name, e-mail address, and phone number. Also, create a text file that contains the names, e-mail addresses, and phone numbers for at least five people. When the application starts, it should read the data from the file and create a PersonEntry object for each person’s data. The PersonEntry objects should be added to...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might use to represent a character within the game. A character should include six stats as instance variables – strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int). Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable. In addition, provide a method named getStatsTotal that calculates the...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
How to make an application for windows using c# ?
How to make an application for windows using c# ?
must be written in c# using windows forms not console Scenario: Samediff bank has a 25-year...
must be written in c# using windows forms not console Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that serves as a healthcare billing management system. This application is a multiform project (Chapter 9) with three buttons. The "All Accounts" button allows the user to see all the account information for each patient which is stored in an array of class type objects (Chapter 9, section 9.4).The "Charge Service" button calls the Debit method which charges the selected service to the patient's account...
Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it...
Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it MPGCalculator Build a form that looks like the form in the video provided. The form consists of 4 labels, 2 textboxes and 3 buttons Name all controls properly. Certain labels do not have to be named Pay attention to video and set all design time properties accordingly. The "x" should be a hot key for the exit button When Calculate is clicked, you should...
Create a Windows application in C# that can be used to change the form color. Your...
Create a Windows application in C# that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT