Você está na página 1de 2

Anidamiento de sentencias

Private Sub cmdcerrar_Click() frmmenucal.Show End Sub Private Sub cmddia_Click() Dim x As
Integer x = InputBox("dame un numero") If (x = 1) Then MsgBox ("es lunes") ElseIf (x = 2) Then
MsgBox ("es martes") ElseIf (x = 3) Then MsgBox ("es miercoles") ElseIf (x = 4) Then MsgBox
("es jueves") ElseIf (x = 5) Then MsgBox ("es viernes") ElseIf (x = 6) Then MsgBox ("es sabado")
ElseIf (x = 7) Then MsgBox ("es domingo") Else MsgBox "ese dia no existe", vbCritical, "error"
End If End Sub

Private Sub cmdnu_Click() Dim x As Integer Dim y As Integer x = InputBox("dame un numero")

y = InputBox("dame otro numero") If (x >= 0) Then r = x + y MsgBox "tu resultado es " & r,
vbExclamation, "jugando" If (y < 0) Then r = y * 2 MsgBox "tu resultado es" & r, vbExclamation,
"jugando" ElseIf (x = y) Then r = x * y MsgBox "tu resultado es:" & r, vbExclamation, "jugando"
Else End If End If End Sub

Private Sub cmdpnn_Click() Dim x As Integer x = InputBox("dame un numero") If (x = 0) Then


MsgBox ("es neutro") ElseIf (x >= 1) Then MsgBox ("es positivo") Else MsgBox ("es negativo")
End If End Sub

Caluladora

Dim x As Integer Dim op As Integer Dim r As Double Private Sub cmdcero_Click() txtpantalla.Text
= txtpantalla.Text & 0 End Sub Private Sub cmdcerrar_Click() frmmenucal.Show
calculadora12.Hide End Sub Private Sub cmdcinco_Click() txtpantalla.Text = txtpantalla.Text &
5End Sub Private Sub cmdclean_Click() txtpantalla = " " End Sub Private Sub cmdcuatro_Click()
txtpantalla.Text = txtpantalla.Text & 4 End Sub Private Sub cmddos_Click() txtpantalla.Text =
txtpantalla.Text & 2 End Sub Private Sub cmdentre_Click() x = txtpantalla.Text op = 4
txtpantalla.Text = " " End Sub Private Sub cmdigual_Click() If (op = 1) Then r = x +
txtpantalla.Text txtpantalla.Text = r ElseIf (op = 2) Then r = x * txtpantalla.Text
txtpantalla.Text = r ElseIf (op = 3) Then r = x - txtpantalla.Text txtpantalla.Text = r Else r = x /
txtpantalla.Text txtpantalla.Text = r End If End Sub Private Sub cmdmas_Click() x =
txtpantalla.Text op = 1 txtpantalla.Text = " " End Sub Private Sub cmdmenos_Click() x =
txtpantalla.Text op = 3 txtpantalla.Text = " " End Sub Private Sub
cmdnueve_Click()txtpantalla.Text = txtpantalla.Text & 9 End Sub Private Sub cmdocho_Click()
txtpantalla.Text = txtpantalla.Text & 8 End Sub Private Sub cmdpunto_Click() txtpantalla.Text =
txtpantalla.Text & "." End Sub Private Sub cmdpor_Click() x = txtpantalla.Text op = 2
txtpantalla.Text = " " End Sub Private Sub cmdseis_Click() txtpantalla.Text = txtpantalla.Text & 6
End Sub Private Sub cmdsiete_Click() txtpantalla.Text = txtpantalla.Text & 7 End Sub

Ejercicios con if simple Private Sub cmd_Click() Dim x As Integer x = InputBox("dame un


numero") If (x = 1) Then MsgBox "atinaste", vbExclamation, "jugando" Else MsgBox "te
equivocaste", vbCritical, "error" End If End Sub Private Sub cmdat_Click() Dim x As Integer
x = InputBox("dame un numero") If (x = 1) Then MsgBox "le atinaste", vbExclamation, "jugando"
Else MsgBox "sigue intentando", vbCritical, "error" End If End Sub Private Sub
cmdcerrar_Click() frmmenucal.Show comparacion.Hide End Sub Private Sub
cmdecuacion_Click() Dim y As Integer y = InputBox("dame un numero") If (y >= 0) Then r = 2 * y
* y * y + y * y – 3 MsgBox ("el resultado es") & r, vbExclamation, "el resultado es" Else
MsgBox ("la ecuacion no puede ser evaluada"), vbCritical, "error" End If End Sub Private Sub
cmdmayor_Click() Dim x As Integer x = InputBox("dame un numero") If (x >= 15) Then r = (x *
3) MsgBox ("el resultado es ") & r, vbExclamation, "el resultado es " Else r = (x * 2) MsgBox ("tu
resultado es ") & r, vbExclamation, " el resultado es " End If End Sub Private Sub
cmdpon_Click() Dim x As Integer x = InputBox("dame un numero") If (x > 0) Then MsgBox ("es
positivo") Else MsgBox ("es negativo") End If End Sub Private Sub cmdsalir_Click() End End
Sub Private Sub cmduno_Click() Dim x As Integer Dim y As Integer x = InputBox("dame un
numero") y = InputBox("dame otro numero") If (x = y) Then MsgBox "le atinastes",
vbExclamation, " son iguales" Else MsgBox "sigue participando", vbCritical, "error" End If End
Sub

Menú Private Sub calculadora_Click() calculadora12.Show End Sub Private Sub


Conversiones_Click() Dim x As String Dim C As Integer Dim f As Integer Dim r As Double x =
InputBox("Que opcion deseas realizar" & vbCrLf & "a)Convertir grados C° a F°" & vbCrLf &
"b)Convertir grados F° a C°") Select Case LCase(x) Case "a" C = InputBox("Dame los grados
Centigrados") r = C * 1.8 + 32 MsgBox "El resultado es: " & r, vbInformation, "C° a F°" Case "b"
f = InputBox("Dame los grados Farenheit") r = (f - 30) / 1.8 MsgBox "El resultado es: " & r,
vbInformation, "F° a C°" Case Else MsgBox "Esa opcion no existe", vbCritical, "Estas mal"End
Select End Sub

Private Sub Diasvividos_Click() Dim d As Integer, m As Integer, A As Integer, Añ As Integer, r3 As


Long, r2 As Integer, EDAD As Long Dim aa As Integer, da As Integer, ma As Integer, mt As Integerd
= InputBox("ESCRIBE TU DIA DE NACIMIENTO") m = InputBox("ESCRIBE TU MES DE
NACIMIENTO") Añ = InputBox("ESCRIBE TU AÑO DE NACIMIENTO") aa = InputBox("introduce el
año actual") A = aa – Añ r3 = A * 365 mt = m – 1 EDAD = r3 + r2 + d MsgBox "el numero de dias
vividos son: " & EDAD, vbCritical, "TU EDAD" If (mt = 1) Then r2 = 31 ElseIf (mt = 2) Then r2 = 28
ElseIf (mt = 3) Then r2 = 31 ElseIf (mt = 4) Then r2 = 30 ElseIf (mt = 5) Then r2 = 31 ElseIf (mt = 6)
Then r2 = 30 ElseIf (mt = 7) Then r2 = 31 ElseIf (mt = 8) Then r2 = 31 ElseIf (mt = 9) Then r2 = 30
ElseIf (mt = 10) Then r2 = 31 ElseIf (mt = 11) Then r2 = 30 ElseIf (mt = 12) Then r2 = 31 Else
MsgBox "TUS DATOS SON ERRONEOS", vbCritical, "ERROR" End If End Sub Private Sub
Ejercicios_Click() comparacion.Show End Sub Private Sub Ejerciciosss_Click()
anidamientogre.Show End Sub Private Sub Estacionamiento_Click() Dim x As Integer Dim y As
Integer x = InputBox("Dame el numero total de horas") y = InputBox("Dame el numero total de
minutos") If (y > 10) Then y = 8 Else y = 0 End If f (x = 1) Then MsgBox "Total a pagar
$12.00", vbExclamation Else If (x > 1) Then tp = (((x - 1) * 8) + 12 + y) MsgBox "total a pagar " &
tp, vbExclamation End If End If End Sub Private Sub Form_Load() End Sub Private Sub
salir_Click() End End Sub Private Sub Sintaxis_Click() secase.Show End Sub Private Sub
Sintaxise_Click() sintaxis1.Show End Sub Private Sub Sintaxisss_Click() Form1.Show End Sub

Você também pode gostar