Question
I'm working on http://www.chegg.com/homework-help/video-collectioncreate-application-stores-data-dvd-collectio-chapter-9-problem-4pc-solution-9780134400150-exc assingment and somwhere my code went wrong I get an error whenever I try to save the movie list. This is
I'm working on http://www.chegg.com/homework-help/video-collectioncreate-application-stores-data-dvd-collectio-chapter-9-problem-4pc-solution-9780134400150-exc assingment and somwhere my code went wrong I get an error whenever I try to save the movie list.
This is my code so far
Imports System.IO Imports System.IO.FileStream
Public Class MovieCollection Structure MovieCollection Dim nameOfVideo As String Dim yearOfProduction As Integer Dim runTime As String Dim ratingForVideo As String End Structure Dim mytext As StreamWriter Dim mysearchFile As StreamReader
Private Sub mnuFileSave_Click(sender As Object, e As EventArgs) Handles mnuFileSave.Click Dim MRecord As MovieCollection MRecord.nameOfVideo = txtVideoName.Text MRecord.yearOfProduction = Convert.ToInt32(txtYearProduced.Text) MRecord.runTime = txtRunTime.Text MRecord.ratingForVideo = txtRating.Text mytext = File.CreateText("c:\Collection.txt") mytext.WriteLine(MRecord.nameOfVideo) mytext.WriteLine(MRecord.yearOfProduction) mytext.WriteLine(MRecord.runTime) mytext.WriteLine(MRecord.ratingForVideo) mytext.Close() reset() End Sub
Private Sub mnuReportView_Click(sender As Object, e As EventArgs) Handles mnuReportView.Click Dim movieReport As String movieReport = "Report of Movie Collection" + vbNewLine mysearchFile = File.OpenText("D:\Collection.txt") Try While Not mysearchFile.EndOfStream movieReport += mysearchFile.ReadLine() + " " movieReport += mysearchFile.ReadLine() + " " movieReport += mysearchFile.ReadLine() + " " movieReport += mysearchFile.ReadLine() + " " movieReport += vbNewLine End While Catch ex As Exception End Try MessageBox.Show(movieReport) End Sub
Private Sub mnuSearch_Click(sender As Object, e As EventArgs) Handles mnuSearch.Click mysearchFile = File.OpenText("D:\Collection.txt") Dim saveName As String Dim flagValue As Integer flagValue = 0 saveName = InputBox("Enter Movie Name") Dim MovieSearchRecord As MovieCollection Try While Not mysearchFile.EndOfStream MovieSearchRecord.nameOfVideo = mysearchFile.ReadLine MovieSearchRecord.yearOfProduction = CInt(mysearchFile.ReadLine) MovieSearchRecord.runTime = mysearchFile.ReadLine MovieSearchRecord.ratingForVideo = mysearchFile.ReadLine If MovieSearchRecord.nameOfVideo.Equals(saveName) Then flagValue = 1 Exit While End If
End While If flagValue.Equals(1) Then txtVideoName.Text = MovieSearchRecord.nameOfVideo.ToString txtYearProduced.Text = MovieSearchRecord.yearOfProduction.ToString txtRunTime.Text = MovieSearchRecord.runTime.ToString txtRating.Text = MovieSearchRecord.ratingForVideo.ToString Else MessageBox.Show("Records do not exist") reset() End If Catch ex As Exception
End Try End Sub
Private Sub mnuClose_Click(sender As Object, e As EventArgs) Handles mnuClose.Click Me.Close() End Sub
Private Sub mnuHelp_Click(sender As Object, e As EventArgs) Handles mnuHelp.Click MessageBox.Show("1.Enter the movie info in the textboxes and then click save." + vbNewLine + "2. Click Report to make a report of movie info saved in the file." + vbNewLine + "3. Click Search to search the movie info already saved.") End Sub Public Sub reset() txtVideoName.Text = "" txtYearProduced.Text = "" txtRunTime.Text = "" txtRating.Text = "" End Sub
End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started