Carga de ComboBox y Calculo de Edad en Visual BasicsteemCreated with Sketch.

in #programming7 years ago

Carga de ComboBox y Calculo de Edad en Visual Basic

visual basic.png

CONSIGNA
Crear un formulario que permita utilizando ComboBox ingresar la fecha de nacimiento
(aaaa/m/dd) y a partir de ello calcular la edad exacta de la persona.
Observaciones:

  • Se debe identificar si el año es bisiesto.
  • Se debe cargar automáticamente el combo días de acuerdo al mes.

INTERFAZ

01.png

CÓDIGO FUENTE

Private Sub Combo1_Click()
Combo2.Enabled = True
Combo2.Clear
Combo3.Clear
For i = 1 To 12
Combo2.AddItem i
Next i
End Sub


Private Sub Combo2_Click()
Combo3.Clear
If Val(Combo2.Text) = 2 Then
......If (Val(Combo1.Text) Mod 4 = 0 And Val(Combo1.Text) Mod 100 <> 0 Or Val(Combo1.Text)
......Mod 400 = 0) Then
......dias = 29
......Else
......dias = 28
......End If
Else
......If Val(combo2text) Mod 2 = 0 Then
......dias = 30
......Else
......dias = 31
......End If
End If
Combo3.Enabled = True
For i = 1 To dias
......Combo3.AddItem i
Next i
End Sub
Private Sub Combo3_Click()
nacimiento = Combo3.Text + "/" + Combo2.Text + "/" + Combo1.Text
Text1.Text = Int(DateDiff("m", nacimiento, Date) / 12)
'datediff("formato",fecha1,fecha2)devuelve la diferencia entre dos fechas'
'formatos m: meses, d: días, yyyy: años'
'En este caso para conseguir la edad exacta se hace la diferencia en meses'
'al resultado se divide por 12'
'por último se utiliza int(variable) para redondear el resultado'
End Sub


Private Sub Form_Load()
LIMPIAR_Click
End Sub


Private Sub LIMPIAR_Click()
Combo1.Clear
Combo2.Clear
Combo3.Clear
Combo2.Enabled = False
Combo3.Enabled = False
Text1.Text = ""
For i = 2015 To 1915 Step -1
......Combo1.AddItem i
Next i
End Sub


Private Sub SALIR_Click()
Unload Me
End Sub

Sort:  

Congratulations @mauricioeb83! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote
Award for the number of upvotes received
You made your First Vote
You made your First Comment
Award for the number of posts published
Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @mauricioeb83! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received
You published 4 posts in one day

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

thank you very much

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 66565.59
ETH 3503.87
USDT 1.00
SBD 2.72