Ejercicios de programación .net (nivel inicial)

Se muestra el funcionamiento de los conceptos básicos para programar en .net Se muestra el funcionamiento de los conceptos básicos para programar en .net

10.04.2019 Views

Día del Año, con BISIESTO Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim año, mes, dia, a, bisiesto As Integer año = Mid(TextBox1.Text, 1, 4) mes = Mid(TextBox1.Text, 6, 2) a = Mid(TextBox1.Text, 9, 2) bisiesto = año Mod 4 If año < 1900 Or año > 2014 Then MsgBox("INGRESE OTRO AÑO") Else If mes 12 Then MsgBox("INGRESE OTRO MES") Else Select Case mes Case 1, 3, 5, 7, 8, 10, 12 dia = 31 Case 4, 6, 9, 11 dia = 30 Case 2 If bisiesto = 0 Then dia = 29 Else dia = 28 End If End Select If a > dia Then MsgBox("Ingrese otro dia") Else MsgBox("Fecha valida") End If End If End If End Sub End Class Leonel Navarrete

Bucle For Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim resp As Integer Dim I As Integer Dim R As Integer R = Val(TextBox1.Text) For I = 1 To 10 Step 1 resp = I * R ListBox1.Items.Add(I & " * " & R & " = " & resp) Next End Sub End Class Leonel Navarrete

Día <strong>de</strong>l Año, con BISIESTO<br />

Public Class Form2<br />

Private Sub Button1_Click(ByVal sen<strong>de</strong>r As System.Object, ByVal e As<br />

System.EventArgs) Handles Button1.Click<br />

Dim año, mes, dia, a, bisiesto As Integer<br />

año = Mid(TextBox1.Text, 1, 4)<br />

mes = Mid(TextBox1.Text, 6, 2)<br />

a = Mid(TextBox1.Text, 9, 2)<br />

bisiesto = año Mod 4<br />

If año < 1900 Or año > 2014 Then<br />

MsgBox("INGRESE OTRO AÑO")<br />

Else<br />

If mes 12 Then<br />

MsgBox("INGRESE OTRO MES")<br />

Else<br />

Select Case mes<br />

Case 1, 3, 5, 7, 8, 10, 12<br />

dia = 31<br />

Case 4, 6, 9, 11<br />

dia = 30<br />

Case 2<br />

If bisiesto = 0 Then<br />

dia = 29<br />

Else<br />

dia = 28<br />

End If<br />

End Select<br />

If a > dia Then<br />

MsgBox("Ingrese otro dia")<br />

Else<br />

MsgBox("Fecha valida")<br />

End If<br />

End If<br />

End If<br />

End Sub<br />

End Class<br />

Leonel Navarrete

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!