Public Class Form1 Sub Comparacion() Dim edad As Integer Dim

Anuncio
Public Class Form1
Sub Comparacion()
Dim edad As Integer
Dim etapa As String
edad = 4
If edad < 5 Then
etapa = "niñes"
MsgBox(etapa)
ElseIf edad < 14 Then
etapa = "adolecente"
MsgBox(etapa)
ElseIf edad < 25 Then
etapa = "juventud"
MsgBox(etapa)
ElseIf edad < 40 Then
etapa = "adultez"
MsgBox(etapa)
Else
etapa = "vejez"
MsgBox(etapa)
End If
End Sub
Private Sub btnIfElse01_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Call Comparacion()
End Sub
Private Sub btnIfElse02_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button7.Click
Call Comparacion()
End Sub
Private Sub btnIfElse03_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button8.Click
Call Comparacion()
End Sub
Private Sub btnSelectCase_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
Dim edad As Integer
Dim etapa As String
edad = 4
Select Case edad
Case Is < 5
etapa = "niñes"
MsgBox(etapa)
Case Is < 14
etapa = "adolecente"
MsgBox(etapa)
Case Is < 25
etapa = "juventud"
MsgBox(etapa)
Case Is < 40
etapa = "adultez"
MsgBox(etapa)
Case Else
etapa = "vejez"
MsgBox(etapa)
End Select
End Sub
Private Sub btnFor_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim x As Integer
For x = 1 To 10 Step 1
MsgBox(2 * x)
Next
End Sub
Private Sub btnDoWhile_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button4.Click
Dim x As Integer
x = 1
Do While x <= 10
MsgBox(2 * x)
x = x + 1
Loop
End Sub
Private Sub btnDoUntil_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button5.Click
Dim x As Integer
x = 1
Do Until x > 10
MsgBox(2 * x)
x = x + 1
Loop
End Sub
End Class
Descargar