Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2005, 02:12 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting non 24hr time into number

Hello All,

Very new to .Net :)

I'm trying to convert Non 24hr Time: 150:45 to 150.75 or
26:15 to 26.25 for some simple conversions that I use at work.

I'm pretty sure its either a right or mid function?? from doing this in Excel or Access.

but this has me stumped......at least for now.

Some help on this would be great.


    Private Sub txtOutput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged

        'Declare
        Dim strTime As String

        'Convert
        strTime = CDec(txtInput.Text)
        'Format
        FormatNumber(txtInput.Text)
        'Output
        lblOutput.Text = strTime

FYI: I know there should be a lot more code to this, but it's a beginning :)


 
Old June 9th, 2005, 08:54 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You could convert the entered time (150:45) into the variable type TimeSpan, then use the properties on that to get at the parts (hours, minutes) then just do the math [ TimeSpan.Hours + (TimeSpan.Minutes/60) ].

http://msdn.microsoft.com/library/en...mberstopic.asp

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Epoch Time to Readable Date maigoro ASP.NET 3.5 Basics 2 April 12th, 2008 11:42 AM
Converting number to hh:mm dlyles Beginning VB 6 8 September 19th, 2006 12:27 PM
converting database driver in run time shun Pro VB Databases 0 July 16th, 2004 10:17 AM
Converting a string to a number steve456 Javascript How-To 2 November 17th, 2003 06:01 PM
Time conversions from 24hr to am/pm Blaise Classic ASP Basics 2 July 14th, 2003 09:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.