I am a beginner when it comes to VB.net and have a school project that I am struggling with. I have a project where I have a main form and from that form I need to allow a user to select a text file that opens in a child form. I am using the open file dialog component for the user to select the file but am struggling with how to pass that to the child form. I am not looking for a hand out of a finished program but help on what I am missing to get this to function.
Below is what I have for the code so far:
Private Sub OpenFileToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenFileToolStripMenuItem.Click
' Variable for file to open
Dim ResponseDialogResult As DialogResult
Dim FileName As String
'Browse for file to open and filter on text files
With OpenFileDialog1
' Begin in current folder
.InitialDirectory = Directory.GetCurrentDirectory()
.Title = "Select Text File."
ResponseDialogResult = .ShowDialog()
End With
If ResponseDialogResult <> Windows.Forms.DialogResult.Cancel Then
FileName = OpenFileDialog1.FileName
Dim AChildForm As New ChildForm
With AChildForm
.MdiParent = Me
.Text = FileName.ToString
.Show()
End With
End If
As you can see I have no code here to pass what is selected via the Opendialog to the new child form as I have not found a way using the textbook that we followed.
Thanks in advance for any advice posted.
Below is what I have for the code so far:
Private Sub OpenFileToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenFileToolStripMenuItem.Click
' Variable for file to open
Dim ResponseDialogResult As DialogResult
Dim FileName As String
'Browse for file to open and filter on text files
With OpenFileDialog1
' Begin in current folder
.InitialDirectory = Directory.GetCurrentDirectory()
.Title = "Select Text File."
ResponseDialogResult = .ShowDialog()
End With
If ResponseDialogResult <> Windows.Forms.DialogResult.Cancel Then
FileName = OpenFileDialog1.FileName
Dim AChildForm As New ChildForm
With AChildForm
.MdiParent = Me
.Text = FileName.ToString
.Show()
End With
End If
As you can see I have no code here to pass what is selected via the Opendialog to the new child form as I have not found a way using the textbook that we followed.
Thanks in advance for any advice posted.