Diseñar un algoritmo que permita ingresar la hora, minutos y segundos y que me calcule la hora en el siguiente segundo ("0=< H =<23", "0=< M =<59" "0=< S=<59").
Solución
- Entrada: 8 : 1:59
- Salida: 8h:2m:0s
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim h, m, s As Integer h = TextBox1.Text m = TextBox2.Text s = TextBox3.Text If (h < 24 And m < 60 And s < 60) Then If (s < 59 And s >= 0) Then TextBox4.Text = Trim(h) + "h " + Trim(m) + "m " + Trim(s + 1) + "s" Else If (s = 59) Then If (m = 59) Then If (h = 23) Then TextBox4.Text = "00h 00m 00s" Else TextBox4.Text = Trim(h + 1) + "h " + "00m 00s" End If Else TextBox4.Text = Trim(h) + "h " + Trim(m + 1) + "m 00s" End If End If End If Else TextBox4.Text = "Fuera de rango" End If End Sub End Class
0 comentarios:
Publicar un comentario