' Visual Basic 2008 9.0 .NET Examples - Iterations - Introduction to Visual Basic : Module Exercise3Solution Sub Main() Dim totalSeconds, remainingSeconds As Integer Dim days, hours, minutes, seconds As Integer ' Do Console.WriteLine("Seconds ?") totalSeconds = Console.ReadLine() If totalSeconds = 0 Then Console.WriteLine("End.") Else If totalSeconds < 0 Then Console.WriteLine("Error : " & _ "Only positive values are accepted !") Else remainingSeconds = totalSeconds days = remainingSeconds \ 86400 remainingSeconds = remainingSeconds - days * 86400 hours = remainingSeconds \ 3600 remainingSeconds = remainingSeconds - hours * 3600 minutes = remainingSeconds \ 60 seconds = remainingSeconds - minutes * 60 Console.WriteLine("Result :") If days > 0 Then Console.WriteLine(days & " days") End If If hours > 0 Then Console.WriteLine(hours & " hours") End If If minutes > 0 Then Console.WriteLine(minutes & " minutes") End If If seconds > 0 Then Console.WriteLine(seconds & " seconds") End If End If End If Loop Until totalSeconds = 0 ' Console.ReadLine() End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.