Factorial de Un Numero

Potrebbero piacerti anche

Sei sulla pagina 1di 3

mircoles, 12 de noviembre de 2008 Codigo para hallar el factorial de un numero Dim res, num1, cont As Double Private Sub

Command1_Click() res = 1 For cont = 1 To num1 res = res * cont Text2.Text = res Next End Sub Private Sub Command2_Click() Text1.Text = " " Text2.Text = " " Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub

Private Sub Text1_Change() If Text1.Text <> " " Then num1 = Val(Text1.Text) End If End Sub

Dim num1, resp, resp2 As Double Private Sub Command1_Click() If num1 Mod 60 = 0 Then resp2 = num1 / 60 Label2.Caption = "Hay " & resp2 & " minuto(s)" Else resp = -(num1 Mod 60) + 60 If (num1 Mod 60) = 0 Then resp2 = ((resp + num1) / 60) Else resp2 = ((resp + num1) / 60) End If Label2.Caption = "Faltan " & resp & " segundos para completar " & resp2 & " minu to(s)" End If End Sub

Private Sub Command2_Click() Text1.Text = " " Label2.Caption = " " Text1.SetFocus num1 = 0 resp = 0 End Sub Private Sub Command3_Click() End End Sub Private Sub Text1_Change() If Text1.Text <> " " Then num1 = Val(Text1.Text) End If End Sub

mircoles, 12 de noviembre de 2008 Codigo para hallar los minutos, horas y dias Dim num1, m, h, d As Integer Private Sub Command1_Click() If Text1.Text <> " " Then If num1 \ 60 = 0 And num1 \ 1440 = 0 Then m = num1 Label2.Caption = "Hay " & m & " minutos" ElseIf num1 \ 60 <> 0 And num1 \ 1440 = 0 Then If num1 Mod 60 = 0 Then h = num1 / 60 Label2.Caption = "Hay " & h & " horas" Else h = num1 \ 60 m = num1 Mod 60 Label2.Caption = "Hay " & h & " horas" & " con " & m & " minutos" End If ElseIf num1 \ 60 <> 0 And num1 \ 1440 <> 0 Then If num1 Mod 1440 = 0 Then d = num1 \ 1440 Label2.Caption = "Hay " & d & " dias" ElseIf num1 Mod 1440 <> 0 And (num1 Mod 1440) Mod 60 = 0 Then d = num1 \ 1440 h = (num1 Mod 1440) \ 60 Label2.Caption = "Hay " & d & " dia(s)" & " con " & h & " hora(s)" ElseIf num1 Mod 1440 <> 0 And (num1 Mod 1440) Mod 60 <> 0 Then d = num1 \ 1440 h = (num1 Mod 1440) \ 60 m = (num1 Mod 1440) Mod 60 Label2.Caption = "Hay " & d & " dia(s)" & " con " & h & " hora(s) y " & m & " mi nuto(s)" End If End If Else MsgBox ("Ingrese un numero")

Text1.SetFocus End If End Sub Private Sub Command2_Click() Text1.Text = " " Label2.Caption = " " Text1.SetFocus num1 = 0 m = 0 d = 0 h = 0 End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Text1.Text = " " End Sub Private Sub Text1_Change() If Text1.Text <> " " Then num1 = Val(Text1.Text) End If End Sub

Potrebbero piacerti anche