Question: How would I add a print method and print page event to the Video Collection problem in Visual Basics so I can print a report

How would I add a print method and print page event to the Video Collection problem in Visual Basics so I can print a report listing all the video reocords in the file?

Here is what I have so far:

Public Class VideoCollection

'Declaration of Structure Structure VideoCollection

'Local variables Dim nameOfvideo As String 'To hold name of video Dim yearOfproduction As Integer 'To hold year of video production Dim runTime As String 'To hold video run time Dim ratingForvideo As String 'To hold the ratings of the video

'End Stucture End Structure

'Declaration of variables for file Dim mytextFile As StreamWriter Dim mysearchFile As StreamReader

Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click

'Declaration of Structure variable Dim videoRecord As VideoCollection

'Get video name. videoRecord.nameOfvideo = txtVideoName.Text

'Get year produced. videoRecord.yearOfproduction = Convert.ToInt32(txtYearProduced.Text)

'Get running time. videoRecord.runTime = txtRuntime.Text

'Get rating videoRecord.ratingForvideo = txtRating.Text

'Open file mytextFile = File.CreateText("D:\VideoCollection.txt")

'Write the data mytextFile.WriteLine(videoRecord.nameOfvideo) mytextFile.WriteLine(videoRecord.yearOfproduction) mytextFile.WriteLine(videoRecord.runTime) mytextFile.WriteLine(videoRecord.ratingForvideo)

'Close the file. mytextFile.Close()

'Call function reset() Reset()

End Sub

Private Sub ReportToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ReportToolStripMenuItem.Click

'Local vairables Dim videoReport As String videoReport = "Report on Video" + vbNewLine

'Open file mysearchFile = File.OpenText("D:\VideoCollection.txt")

Try 'Read all the lines in the file While Not mysearchFile.EndOfStream videoReport += mysearchFile.ReadLine() + "" + vbNewLine videoReport += mysearchFile.ReadLine() + "" + vbNewLine videoReport += mysearchFile.ReadLine() + "" + vbNewLine videoReport += mysearchFile.ReadLine() + "" + vbNewLine videoReport += vbNewLine End While

Catch ex As Exception

End Try

'Display video content report MessageBox.Show(videoReport)

End Sub

Private Sub SearchToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SearchToolStripMenuItem.Click 'Open file mysearchFile = File.OpenText("D:\VideoCollection.txt")

'Local Variables Dim saveName As String Dim flagValue As Integer flagValue = 0

'Get video name saveName = InputBox("Enter Video Name")

'Declaration of structure variable Dim videoSearchRecord As VideoCollection

Try

'Read all the lines in the file While Not mysearchFile.EndOfStream

videoSearchRecord.nameOfvideo = mysearchFile.ReadLine() 'Read video name line videoSearchRecord.yearOfproduction = mysearchFile.ReadLine() 'Read year of production line videoSearchRecord.runTime = mysearchFile.ReadLine() 'Read running time line videoSearchRecord.ratingForvideo = mysearchFile.ReadLine() 'Read ratings for video line

'Make sure the video searched for matches videos on file If videoSearchRecord.nameOfvideo.Equals(saveName) Then flagValue = 1

End If

End While

'If video found then display video information If flagValue.Equals(1) Then txtVideoName.Text = videoSearchRecord.nameOfvideo.ToString() txtYearProduced.Text = videoSearchRecord.yearOfproduction.ToString() txtRuntime.Text = videoSearchRecord.runTime.ToString() txtRating.Text = videoSearchRecord.ratingForvideo.ToString()

Else

MessageBox.Show("Records do not exist")

Reset()

End If

Catch ex As Exception

End Try

End Sub

Private Sub CloseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CloseToolStripMenuItem.Click

'Close VideoCollection form Me.Close() End Sub

Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem.Click 'Display explination on how to use program MessageBox.Show("1. Enter the video information in the text boxes and then click save when done." + vbNewLine + "2. Click the Report menu to generate a video report on the saved information" + vbNewLine + "3. Click search to search for the video information already saved by entering" + " the movie title.")

End Sub

Public Sub reset()

'Clear text boxes txtVideoName.Text = "" txtYearProduced.Text = "" txtRuntime.Text = "" txtRating.Text = ""

End Sub

End Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!