Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

VS 2010 Referencing an open form's control

$
0
0
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'."

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

Any help would be much appreciated.

Viewing all articles
Browse latest Browse all 27355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>