VB.net code for this?

If lblTIME.Text(Code for between a time eg:    05 to 12) Then
End If

        lblTIME.Text = DateTime.Now.ToString("HH")
        lblDATE.Text = DateTime.Now.ToString("yyyy-MM-dd")

        If lblTIME.Text = (??????????????????????) Then
        End If

Open in new window

Rowel VirgoVisual Studio .NETAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try like:

lblTIME.Text = DateTime.Now.ToString("HH")

Dim t as integer = convert.toint32(lblTIME.Text)

if t >= 5 and t <= 12 then
  'your stuffs....
end if

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
Nitin SontakkeDeveloperCommented:
Why not instead access the integer property which is readily available, DateTime.Now.Hour. For consistency, you may wish to assign it to a variable instead and then verify.
Rowel VirgoVisual Studio .NETAuthor Commented:
I did this,

If lblTime.Text >= 5 AndAlso lblTime.Text <= 12 Then
Nitin SontakkeDeveloperCommented:
This is all fine, if it is working, however, I feel uncomfortable even looking at it as the whole concept of data-types is being dishonoured (not finding appropriate word...) in which a lot of thinking and design decisions have gone in, for example, generics.

I had rather...

Dim intHour As Int32 = DateTime.Now.Hour
lblTime.Text = intHour.ToString("00")
If intHour >= 5 AndAlso intHour <= 12 Then
End If

Open in new window

Think about it...much better, in my opinion.
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.