Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

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?
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

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
Avatar of sirbounty

ASKER

boy..I feel stupid now... : \
Thanx.
No problems, it happens to all of us. :=)
Hmm - that's generating an InvalidOperationException was unhandled... : $
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...
This is just after my ApplicationEvents.vb's startup runs
myForm.Show()
The error is:
Object reference not set to an instance of an object... not really helpful to me... :(
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<smack> - sorry - another 'dull' moment on my part... :(
Thanx again!
No problem, I should have realized my stupid mistake before I posted it. :=)