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. Turning numbers into a readable time. [modified]

Turning numbers into a readable time. [modified]

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharphelpquestion
2 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.
  • A Offline
    A Offline
    aqzman_
    wrote on last edited by
    #1

    Hi guys, I'm new to programming and the first language I'm trying to learn is VB .NET. It's going pretty well for me, but I have a question and I was wondering if anyone here might be able to help me. I have a text box set up to get information from the user, once that is computed an anwser anywhere from 0 minutes to 180000 minutes. I was wondering if there is a tutorial, or a few lines of code that would be able to change the raw data of 180,000 minutes to days/hours/minutes in three different text boxes. For example, if the user entered a number which got them 129,564 minutes that would display as 89 days 23 hours and 24 minutes. Thanks a lot, aqzman EDIT: I thought this code might work, but it never. Haha. If Time > 1440 Then Time = (Time / 60) Time = (Time / 24) txtDisplay.Text = Time End If If Time < 1440 Then Time = (Time / 60) txtDisplayHour.Text = Time End If If Time < 60 Then Time = (Time) txtDisplayMin.Text = Time End If -- modified at 19:50 Monday 2nd October, 2006

    C 1 Reply Last reply
    0
    • A aqzman_

      Hi guys, I'm new to programming and the first language I'm trying to learn is VB .NET. It's going pretty well for me, but I have a question and I was wondering if anyone here might be able to help me. I have a text box set up to get information from the user, once that is computed an anwser anywhere from 0 minutes to 180000 minutes. I was wondering if there is a tutorial, or a few lines of code that would be able to change the raw data of 180,000 minutes to days/hours/minutes in three different text boxes. For example, if the user entered a number which got them 129,564 minutes that would display as 89 days 23 hours and 24 minutes. Thanks a lot, aqzman EDIT: I thought this code might work, but it never. Haha. If Time > 1440 Then Time = (Time / 60) Time = (Time / 24) txtDisplay.Text = Time End If If Time < 1440 Then Time = (Time / 60) txtDisplayHour.Text = Time End If If Time < 60 Then Time = (Time) txtDisplayMin.Text = Time End If -- modified at 19:50 Monday 2nd October, 2006

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You're on the right track. You need to use the Mod operator ( it's % in C#, I suspect it's Mod in the ever literal VB ). This will return to you the remainder of your division. So, if you have 63 minutes in Time, Time Mod 60 would give you 3, the number of seconds.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      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