Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Minutes to Hours Conversions in VB.NET

Minutes to Hours Conversions in VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharpcomhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jm6k
    wrote on last edited by
    #1

    I'm trying to write a program that will convert minutes to hours. For example, say a user inputs that they had 1,256 minutes logged on somewhere and they wanted to know how much that would be in hours (20.93 hours, but I need it to be displayed as 21 Hours and 55 Minutes.) Is there any built in method or function that .NET can use to calculate values on hourly or minutely fashion? I've tried the dynamic help, but the time functions in there display dates and such. I fear I may have to do it the old fashioned way with many mathimatical hijinx! :(( The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

    D 1 Reply Last reply
    0
    • J Jm6k

      I'm trying to write a program that will convert minutes to hours. For example, say a user inputs that they had 1,256 minutes logged on somewhere and they wanted to know how much that would be in hours (20.93 hours, but I need it to be displayed as 21 Hours and 55 Minutes.) Is there any built in method or function that .NET can use to calculate values on hourly or minutely fashion? I've tried the dynamic help, but the time functions in there display dates and such. I fear I may have to do it the old fashioned way with many mathimatical hijinx! :(( The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

      D Offline
      D Offline
      dynamic
      wrote on last edited by
      #2

      this may help : VbCode:


      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Try
      Dim x As DateTime = New DateTime()
      Dim mins As Double = 120 '/// minutes
      MessageBox.Show(x.AddMinutes(mins)) '/// return the value ( eg: 02:00:00 being 120 minutes )
      Catch ex As Exception
      MessageBox.Show(ex.Message)
      End Try
      End Sub


      :) Vb:


      Public Function TwinsOnWay(ByVal twins As String) As String
      Select Case twins
      Case "Gender"
      Return "Two Girls"
      End Select
      End Function


      J 1 Reply Last reply
      0
      • D dynamic

        this may help : VbCode:


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
        Dim x As DateTime = New DateTime()
        Dim mins As Double = 120 '/// minutes
        MessageBox.Show(x.AddMinutes(mins)) '/// return the value ( eg: 02:00:00 being 120 minutes )
        Catch ex As Exception
        MessageBox.Show(ex.Message)
        End Try
        End Sub


        :) Vb:


        Public Function TwinsOnWay(ByVal twins As String) As String
        Select Case twins
        Case "Gender"
        Return "Two Girls"
        End Select
        End Function


        J Offline
        J Offline
        Jm6k
        wrote on last edited by
        #3

        Hey! Thanks a lot! This is just what I was looking for! Would I have to use the Format Function in able to just return a single value? Such as "2" being the number of hours? Or would I have to use some tricky string functions? :-DCongradulations on the two girls!!!:-D The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups