Winky blinky

In my old vb6 app, I had a label with the date on it.
When the user clicked it, they were presented with a datetimepicker to change the date.
In my timer routine, I had a test loop that if the date differed from today, it would continually flash on/off red/bold until it was set back to today...

I find in http:/Q_21734897.html that to accomplish this in .net, I would be generating a new font object with every blink...
SO....there MUST be a better way...

Whatcha think?
LVL 67
sirbountyAsked:
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.

Fernando SotoRetiredCommented:
Hi sirbounty;

If you place these two lines of code out side any sub or function, at class level then you will only create them once

        Dim fntBold As New Font(Label1.Font, FontStyle.Bold)
        Dim fntNorm As New Font(Label1.Font, FontStyle.Regular)

Then when you want to change the font to Bold or Normal in the label use one of these lines.

        Label1.Font = fntBold
        Label1.Font = fntNorm

Fernando
sirbountyAuthor Commented:
boy..I feel stupid now... : \
Thanx.
Fernando SotoRetiredCommented:
No problems, it happens to all of us. :=)
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

sirbountyAuthor Commented:
Hmm - that's generating an InvalidOperationException was unhandled... : $
sirbountyAuthor Commented:
I've got
Public Class myForm
  Dim fntBold as New Font(lblDate.Font, Fontstyle.bold)
  Dim fntNorm as New Font(lblDate.Font, FontStyle.Regular)

It bombs on the first Dim...
sirbountyAuthor Commented:
This is just after my ApplicationEvents.vb's startup runs
myForm.Show()
sirbountyAuthor Commented:
The error is:
Object reference not set to an instance of an object... not really helpful to me... :(
Fernando SotoRetiredCommented:
Hi sirbounty;

Sorry about that but the Label are not creaated yet. So do it this way

Class level variables

    Dim fntBold As Font
    Dim fntNorm As Font

And at form load create the fonts.

    Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

        fntBold = New Font(Label1.Font, FontStyle.Bold)
        fntNorm = New Font(Label1.Font, FontStyle.Regular)

    End Sub


Fernando

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
sirbountyAuthor Commented:
<smack> - sorry - another 'dull' moment on my part... :(
Thanx again!
Fernando SotoRetiredCommented:
No problem, I should have realized my stupid mistake before I posted it. :=)
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
Visual Basic.NET

From novice to tech pro — start learning today.