I have an application that loads an instance of a form and fills in some of the label controls. The labels get their data from textfile, which also holds the form's name.
How can I reference the form later on to changes some of the controls? I have tried the following, looping through the applications open forms, but this comes back with the error "Unable to cast object of type 'NotifyMe__v1._3.form_SplashScreen' to type 'NotifyMe__v1._3.form_Notification'."
Any help would be much appreciated.
How can I reference the form later on to changes some of the controls? I have tried the following, looping through the applications open forms, but this comes back with the error "Unable to cast object of type 'NotifyMe__v1._3.form_SplashScreen' to type 'NotifyMe__v1._3.form_Notification'."
Code:
For Each frm As form_Notification In My.Application.OpenForms
If frm.Name = pstrCurrentNotifications(x) And frm.Visible = True Then
frm.label_Title.Text = Mid(pstrCurrentNotifications(1), 6).ToUpper.Trim & " incident has been changed"
frm.label_Text.Text = "Something has changed"
frm.label_Summary.MaximumSize = New Size(293, 26)
frm.label_Summary.Text = Mid(pstrCurrentNotifications(3), 9).Trim
frm.label_LastUpdated.Text = "Today at " & Format(Now, "hh:mm")
End If
Next