K
kevininstructor
I have a ListBox on the main form, in the child form when accessing items I
get an error message "Object reference not set to an instance of an object."
here is the code in the child form. Is there something I am missing i.e.
setting the reference to the main form to access ListBox items?
Public Class frmWinZipExecution
Inherits System.Windows.Forms.Form
Public MainForm As frmMainForm ' For accessing calling form
....
Private Sub cmdBuild_Click(ByVal sender As System.Object,....
Dim iFileCount As Integer
Dim iFile As Integer
Try
iFileCount = MainForm.ListBox1.Items.Count
For iFile = 1 To iFileCount - 1
Debug.WriteLine(MainForm.ListBox1.GetItemText(iFile))
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Thanks for any help you can provide,
Kevin
get an error message "Object reference not set to an instance of an object."
here is the code in the child form. Is there something I am missing i.e.
setting the reference to the main form to access ListBox items?
Public Class frmWinZipExecution
Inherits System.Windows.Forms.Form
Public MainForm As frmMainForm ' For accessing calling form
....
Private Sub cmdBuild_Click(ByVal sender As System.Object,....
Dim iFileCount As Integer
Dim iFile As Integer
Try
iFileCount = MainForm.ListBox1.Items.Count
For iFile = 1 To iFileCount - 1
Debug.WriteLine(MainForm.ListBox1.GetItemText(iFile))
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Thanks for any help you can provide,
Kevin