Hi all,

I'm obviously (especially after reading my post through) a newb to vb.net. However, I'm hoping that someone would be kind enough to guide me through.

This is for a final project at school and I'm stuck.

I'm working on a movie catalog and I am trying to get the child form to show up and read data from a text file. The data from the parent form is as follows:

Public Class Form1

Dim movieList As New List(Of String)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
numMoviesLabel.Text = movieList.Count
End Sub

Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim movie As String = titleBox.Text

If DoBinarySearch(movie) <> -1 Then
MessageBox.Show("""" & movie & """ is already in the catalog")
Else
AddMovie(movie)
DisplayMovies()
titleBox.Text = ""
numMoviesLabel.Text = movieList.Count
End If
End Sub

Private Sub AddMovie(ByVal movie As String)
movieList.Add(movieList.Count)
If movieList.Count = 1 Then
movieList(0) = movie
Else
Dim i As Integer = movieList.Count - 2
While movie < movieList(i)
movieList(i + 1) = movieList(i)
i = i - 1
If i = -1 Then
Exit While
End If
End While

movieList(i + 1) = movie
End If
End Sub

Private Sub DisplayMovies()
catalogBox.Text = ""
Dim s As String
For i As Integer = 0 To movieList.Count - 1
s = s & movieList(i) & ControlChars.NewLine
Next
catalogBox.Text = s
End Sub

Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
Dim index As Integer = DoBinarySearch(searchBox.Text)
If index = -1 Then
MessageBox.Show("Could not find """ & searchBox.Text & """ in catalog")
Else
MessageBox.Show("""" & searchBox.Text & """ found in catalog at index " & index & ".")
End If
End Sub

Private Function DoBinarySearch(ByVal s As String) As Integer
Dim startIndex As Integer = 0
Dim endIndex As Integer = movieList.Count - 1

While startIndex <= endIndex
Dim mid As Integer = (startIndex + endIndex) / 2
If movieList(mid) = s Then
Return mid
ElseIf s < movieList(mid) Then
endIndex = mid - 1
Else
startIndex = mid + 1
End If
End While

Return -1
End Function


Private Sub deleteAllButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deleteButton.Click
If MessageBox.Show("Really delete all movieList from the catalog?", "Delete All", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
movieList.Clear()
catalogBox.Text = ""
numMoviesLabel.Text = 0
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dialog As New movieListDialog
dialog.ShowDialog()
End Sub

End Class

and for the child form

Imports System.Windows.Forms

Public Class movieListDialog

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movieBox.TextChanged
Dim result As DialogResult = OpenFileDialog1.FileName
If result = Windows.Forms.DialogResult.OK Then
Dim filename As String = OpenFileDialog1.FileName
Dim reader As New IO.StreamReader(filename)
End If
End Sub

End Class


If anyone can please give me their guidance, it would be very much appreciated =D

Ok, I managed to get the data to open and open the child form as well. However, the childform doesn't seem to be reading the data from the text file... HELP!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.