Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9090873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:28:37+00:00 2026-06-16T22:28:37+00:00

I have the following code, which reads the date and time from some DateTimePickers

  • 0

I have the following code, which reads the date and time from some DateTimePickers in VB.

I need to be able to determine if the first value is a 0 or a 1, (eg 09:12… or 12:13…) and if it starts with a 0 to remove that character from the string.

this is what i have so far, but it takes the first character regardless.

    DateFrom = Form1.DateTimePickerFrom.Value.ToString
    DateTo = Form1.DateTimePickerTo.Value.ToString
    VarTimeFrom = Form1.HourTimePickerFrom.Value.ToString
    VarTimeTo = Form1.HourTimePickerTo.Value.ToString

    Dim DateFromManipulated = Left(DateFrom, 10)
    Dim DateToManipulated = Left(DateTo, 10)
    Dim TimeFromManipulated = Right(VarTimeFrom, 9)
    Dim TimeToManipulated = Right(VarTimeTo, 9)

    If Left(DateFromManipulated, 1) = 0 Then

        TimeFromMan = TimeFromManipulated.Remove(0, 1)
    Else
        TimeFromMan = TimeFromManipulated
    End If


    If Left(TimeFromManipulated, 1) = 0 Then

        TimeToMan = TimeToManipulated.Remove(0, 1)
    Else
        TimeToMan = TimeToManipulated
    End If

    Console.WriteLine(DateFromManipulated)
    Console.WriteLine(TimeToMan)
    Console.WriteLine(TimeFromManipulated)
    Console.WriteLine(TimeFromMan)
    Console.WriteLine(DateToManipulated)
    Console.WriteLine(TimeToManipulated)

I get the following:

09/11/2012
1:36:00 
06:36:00 
6:36:00 
08/01/2013
11:36:00 

Thanks in advance!

Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:28:39+00:00Added an answer on June 16, 2026 at 10:28 pm

    A string in VB.NET won’t compare as equal to an integer. You could just reference character zero, though:

    If DateFromManipulated(0) = "0"c Then DateFromManipulated = DateFromManipulated.Substring(1)
    

    … however, you should be just formatting your date the way you want it to begin with:

    Dim dateFrom As String = DateTimePickerFrom.Value.ToString("M/dd/yyyy H:mm:ss")
    

    … for example. (M doesn’t have a leading zero, as opposed to MM; same with H.) You can find all the format strings here: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following bit of C code which reads from a pipe and
I have the following code from a legacy app which currently reads from an
I have the following code which reads in the follow file, append a \r\n
I have following code which works for radio buttons but need to be changed
i have the following code which switches some fullscreen-background-images (fadeOut, fadeIn). setInterval(function() { var
I have a generated file with thousands of lines like the following: CODE,XXX,DATE,20101201,TIME,070400,CONDITION_CODES,LTXT,PRICE,999.0000,QUANTITY,100,TSN,1510000001 Some
I want to know is below code correct ? I have following code which
I have the following code which definitely returns a proper data result if I
I have the following code which is working, I was wondering if this can
I have the following code which is used to upload large files (~6MB) to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.