How to change label text from a calling function
Posted on 2013-06-10
I have a form that calls a routine (located in the general module.vb) and this routine suppose to change the label text that reside on the form. I'm passing as one of the arguments of the routine, the calling form . I don't know why, but an error is generated. When I specify the passing argument to be of type form, the error generated is "Label1 is not a memeber of System.Windows.Forms.Form". When I then change the argument type to be of type object, nothing is returned.
Can someone please tell me what I am doing wrong? Thank you.
[within the calling FORM]
Call qtrByMth(frmProvider.cbxPeriod.Text.Substring(0, 2), Me)
Public Sub qtrByMth(ByVal sQtr As String, ByVal objForm As Object)
Select Case sQtr
objForm.Label1.Text = "July"
objForm.Label4.Text = "July"
CType(objForm.Controls.Find("Label1", True)(0), Label).Text = "January"
objForm.Label2.Text = "August"
objForm.Label5.Text = "August"
objForm.Label3.Text = "September"
objForm.Label6.Text = "September"