In vb.net, how do I set a font size when creating a text box programmatically?

I am programming in vb.net with Visual Studio 2015 Community. I am using the code below to programmatically create a text box. My question is - How can I set the text font size when the box is created. I looked around and found the code between the asterisks below, but I'm getting a compile error saying that Font is ambiguous. This is occurring for the first Font in the using f as Font statement and also the Font after the New in the following line. I'm very new to programming in vb and would appreciate any help you could give. Thanks.

        tbnum.Location = New System.Drawing.Point(30, tvposition)
        tbnum.Size = New Size(45, 20)
        '********************
        Using f As Font = tbnum.Font
            tbnum.Font = New Font(f.FontFamily, f.Size + 2, f.Style)
        End Using
        '********************
        tbnum.Text = panposition.ToString
        tbnum.Name = "tbnum" + panposition.ToString
        tbnum.AllowDrop = True
        tbnum.TabStop = False
        tbnum.TextAlign = HorizontalAlignment.Right
        tbnum.BackColor = ColorTranslator.FromHtml(myYellow)
        tbnum.ReadOnly = True
        tbnum.Enabled = False
        Controls.Add(tbnum)

Open in new window

johnrosshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
Dim objFont As System.Drawing.Font
objFont = New System.Drawing.Font(tbnum.Font.FontFamily, tbnum.Font.Size + 2, f.Style)
tbnum.Font = objFont

Open in new window

0
johnrosshAuthor Commented:
Thanks Najam. I had to get rid of the f.style parameter but once I did that, it worked perfectly. What about bolding the text? How would I do that?
0
Najam UddinCommented:
objFont = New System.Drawing.Font(tbnum.Font.FontFamily, tbnum.Font.Size + 2,FontStyle.Bold)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.