Your BoldLabel won't work because you are declaring LabelName as an
Object, and the Object class doesn't have a Font property.
Instead, assuming BoldLabel is a method of the form with the label
fields, try something like
Private Sub BoldLabel(ByRef LabelName as String)
Me.Controls(LabelName).Font = New System.Drawing.Font("Courier
New", 12.0!, FontStyle.Bold)
End ' Bold Label
-- R.B. Davidson
On Feb 2, 1:41 am, VillageIdiot <[email protected]> wrote:
> Hi All,
>
> I would like to learn how to pass a computed Labelname as an argument
> to a VB.Net 2003 subroutine.
>
> Let's say I have 20 Label form controls called lblLine1 through
> lblLine20, and I want to Bold each Label with a For loop.
>
> '
> ' This routine will change a Label font to Bold
> '
> Private Sub BoldLabel(ByRef LabelName as Object)
> LabelName.Font = New System.Drawing.Font("Courier New", 12.0!,
> FontStyle.Bold)
> End ' Bold Label
> '
> ' This routine will Bold all Lines
> '
> Private Sub BoldAllLines
> Dim Index as Integer
>
> For Index = 1 to 20
> Call BoldLabel(lblLine & Index)
> Next ' Index
>
> End ' Bold All Lines
>
> I know the above statement "Call BoldLabel(lblLine & Index)" is not
> correct but I hope it gives you an idea what I want to accomplish.
>
> Your help will be greatly appreciated.
>
> Thank you in advance for your time.
>
> Village Idiot (newbie)