ASP.NET / VB: Value of this hour as an integer

Posted on 2012-09-16
Last Modified: 2012-09-16
I want the value of this hour as an Integer (not a string).

This does NOT work:

<%@ Page Language="VB" AutoEventWireup="false" %>

Dim THour As Integer = DateTime.Now.ToInt32("H")


Open in new window

Question by:hankknight
    1 Comment
    LVL 82

    Accepted Solution

    This may be clumsy but it appears to do it.
    Dim Ctime = DateTime.Now
    Response.Write(Ctime & "<br>")
    Dim Htime = DateTime.Now.ToString("HH:mm:ss")
    Response.Write(Htime & "<br>")
    Dim Hnum = CInt(Hour(Htime))
    Response.Write(Hnum & "<br>")

    Open in new window


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now