Question

VISUAL BASIC- create a program for managing a "To Do" list. The program will need to...

VISUAL BASIC-

create a program for managing a "To Do" list. The program will need to read and update a text file named ToDoList.txt. The record structure of the file must be: 1) sort order, 2) task name and 3) desired completion date.

When the program starts, it should read the contents file into a structure. The information should then be displayed in a data grid view. The data should be initially sorted by the sort order value. Afterwards, the user should be able to click on a column name to sort the data by that specific column.

The user should be able to add, update and delete tasks. The methods to implement these features are up to you. Please note that each value (sort order, task name and desired completion date) should be saved as a string value.

The program must use StreamReader and StreamWriter objects. The program must also contain exception handling for a missing input file. If the input file is not found, the user should be informed and still be allowed to use the program (i.e. do not automatically close the program).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please read the visual basic code with comments for more explanation and do let me know in the comment box below if you face any errors, I will try my best to explain. Here clicking on update button will write the data to file. Add button will add a blank row to the data grid view for new entry (duble click on the cell to edit the details). Delete button will remove the selected row and then click on update button to save the changes before exiting the application.

Output:

ToDo List Sort Order Task Name Breath Drink Water Desired_Completior 21-04-2017 22-04-2017 Add Update

Text File: (comma separated for better readability)

ToDoList - Notepad File Edit Format View Help 1,Breath, 21-04-2017, 2,Drink water,22-04-2017,

Visual Basic Code:

Imports System.IO 'import for file reading operations

Public Class Form

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Using fileReader As StreamReader = New StreamReader("D:\ToDoList.txt") 'provide correct file path here
Dim fileLine As String = ""
Dim index As Integer = 0
Dim temp(3) As String 'A temp array to store each row at a time (3 columns)
fileLine = fileReader.ReadLine()
While (fileLine <> Nothing) 'read file until the end of the file
temp = fileLine.Split(CChar(",")) 'split the file line with ',' delimeter
'temp(0) contains Sorting Order, temp(1) contains Task Name, temp(2) contains Desired Date
DataGridView.Rows.Add(temp(0), temp(1), temp(2))
fileLine = fileReader.ReadLine()
End While
End Using

Catch err As Exception
'let the user know if any error/exception occurs
MessageBox.Show("Error: " + err.Message)
End Try
End Sub

Private Sub saveList()
Try
Using fileWriter As StreamWriter = New StreamWriter("D:\ToDoList.txt") 'provide correct file path here
For i As Integer = 0 To DataGridView.Rows.Count - 1 Step +1
For j As Integer = 0 To DataGridView.Columns.Count - 1 Step +1
fileWriter.Write(DataGridView.Rows(i).Cells(j).Value.ToString + ",")
Next
fileWriter.WriteLine()
Next
fileWriter.Close()
End Using

Catch err As Exception
'let the user know if any error/exception occurs
MessageBox.Show("Error: " + err.Message)
End Try
End Sub

Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
DataGridView.Rows.Add("", "", "")

End Sub

Private Sub deleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deleteButton.Click
Dim RowIndex As Integer
For i As Integer = 0 To DataGridView.SelectedCells.Count - 1
RowIndex = DataGridView.SelectedCells.Item(i).RowIndex
Next

If RowIndex < 0 Then 'if row selected then alert the user
MsgBox("Please select any row to delete !")
Else
DataGridView.Rows.RemoveAt(RowIndex)
MsgBox("Selected row has been deleted !")
End If
End Sub

Private Sub updateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updateButton.Click
'save the rows to file if update button is clicked
saveList()
MsgBox("Data saved to file successfully.")
End Sub
End Class

Add a comment
Know the answer?
Add Answer to:
VISUAL BASIC- create a program for managing a "To Do" list. The program will need to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Visual C# Homework 2 You are to write a program which will create a class called...

    Visual C# Homework 2 You are to write a program which will create a class called Student Each student has a name age height and weight. These variables should be declared as private. Create the correct constructors and functions. In the main, you will create 5 students. Input the data for the 5 students from a file which already has information in it. Name the file “Information.txt”. After setting up all the data, it is time to sort based on...

  • Write a menu based program implementing the following functions: (0) Write a function called displayMenu that...

    Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...

  • Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc....

    Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc. needs a program in which the date and temperature in Celsius degrees of an industry laboratory are recorded and stored in a sequential file. In addition, you can see the recorded data and convert the temperatures in the following units: Fahrenheit, Kelvin and Rankine. In addition, they want to see a linear graph that reflects how the temperature has fluctuated day by day, for...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • QUESTION 1 Match the following: an SQL command that retrieves data A. Communicate B. RETRIEVE C....

    QUESTION 1 Match the following: an SQL command that retrieves data A. Communicate B. RETRIEVE C. exception D. ReadFile E. STORE F. array G. try - catch block H. Connection I. Disconnect0) J. StreamReader K. Respond L. SQL M. Fork N. Query O. BlowUp P. SELECT Q. Close0 R. StreamWriter S. WriteFile T. UPDATE an SQL command that changes data ., class that can be used to read data from a file , establishing communication with a database a method...

  • C++ Visual Studios - Program - Vector - Simple Create a program that utilizes VECTOR for...

    C++ Visual Studios - Program - Vector - Simple Create a program that utilizes VECTOR for the following topic. Topic: Carl's Cab Stand needs a program to keep track of their daily clients. Your program shall allow the user to enter 10 names. You will then retrieve the names, one by one, from the data structure (using the appropriate method of retrieval for each data structure) and present them on-screen so that Carl knows who to service next. Include a...

  • Usage Usage: sna inputFile userName outputFile Requirements Summary Create a program that will re...

    Usage Usage: sna inputFile userName outputFile Requirements Summary Create a program that will read in the text file containing graph specification of Twitter account followers and write to the output a list of all users within a depth of 3 of the specified root user (the user specified from the userName command line argument), that are not already being followed by that user. The program should be able to create the directed graph from the input file and output the...

  • Write a modularized, menu-driven program to read a file with unknown number of records.

    ==============C++ or java================Write a modularized, menu-driven program to read a file with unknown number of records.Create a class Records to store the following data: first and last name, GPA , an Id number, and an emailInput file has unknown number of records; one record per line in the following order: first and last names, GPA , an Id number, and emailAll fields in the input file are separated by a tab (‘\t’) or a blank space (up to you)No error...

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT