0% found this document useful (0 votes)
35 views2 pages

Ejercicio de Cadena

This document contains code for two different exercises - one that counts characters in a string and one that performs date calculations. The character counting code iterates through each character in a user-entered string, counting lowercase, uppercase and number characters separately. The date calculation code takes a user-entered birthdate, calculates the current age by comparing it to today's date, and also calculates the number of months, weeks and days between the birthdate and current date.

Uploaded by

German Morales
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Ejercicio de Cadena

This document contains code for two different exercises - one that counts characters in a string and one that performs date calculations. The character counting code iterates through each character in a user-entered string, counting lowercase, uppercase and number characters separately. The date calculation code takes a user-entered birthdate, calculates the current age by comparing it to today's date, and also calculates the number of months, weeks and days between the birthdate and current date.

Uploaded by

German Morales
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EJERCICIO DE CADENA

Public Class Form1 Dim cmin, cmay, cnum, cadena As String Dim qmay, qmin, qnum As Integer Dim i As Integer Private Sub BtnExe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExe.Click Dim longitud As Integer = Len(Trim(TxtCadena.Text)) If i >= 0 And i < longitud Then i += 1 Dim caracter As String = Mid(Trim(TxtCadena.Text), i, 1) If Asc(caracter) >= 95 And Asc(caracter) <= 122 Then qmin += 1 LblQmin.Text = Str(qmin) LblCmin.Text = LblCmin.Text + caracter Me.Text = Str(qmin) + " , " + Str(longitud) + " , " + caracter End If If Asc(caracter) >= 65 And Asc(caracter) <= 90 Then qmay += 1 LblQMay.Text = Str(qmay) LblCMay.Text = LblCMay.Text + caracter Me.Text = Str(qmay) + " , " + Str(longitud) + " , " + caracter End If If Asc(caracter) >= 48 And Asc(caracter) <= 57 Then qnum += 1 LblQNum.Text = Str(qnum) LblCNum.Text = LblCNum.Text + caracter Me.Text = Str(qnum) + " , " + Str(longitud) + " , " + caracter End If ElseIf i = 5 Then MsgBox ("Llego el Limite", 0, "Advertencia") TxtCadena.Clear() TxtCadena.Focus() With LblCMay .Text = "" End With With LblQMay .Text = 0 End With With LblCmin .Text = "" End With With LblQmin .Text = 0 End With With LblCNum .Text = "" End With With LblQNum .Text = 0 End With Me.Text = "" End If End Sub End Class

EJERCICIO DE FECHAS

Public Class FrmFecha Dim sem as Double Private Sub Txtaaaa_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtaaaa.KeyPress If e.KeyChar = Chr(13) Then Dim Fecha As String = txtdd.Text + "/" + txtmm.Text + "/" + txtaaaa.Text LblCumple.Text = Format(Fecha, "Long Date") '******Aos******* Dim anocum As Integer = Val(Mid(Fecha, 7, 10)) Dim anoact As Integer = Val(Year(Date.Today)) Dim anos As Integer = Math.Abs(anoact - anocum) LblEdad.Text = Str(anos) '******Mes******* Dim mescum As Integer = Val(Mid(Fecha, 4, 5)) Dim mesact As Integer = Val(Month(Date.Today)) Dim mes As Integer = Math.Abs(mesact - mescum) LblMes.Text = Str(mes) '******Semanas******* Dim semcum As Integer = Val(Mid(Fecha, 1, 2)) Dim semact As Integer = Val(Weekday(Date.Today)) sem = Math.Round(Math.Abs((semcum - semact)) / 4) LblSem.Text = Str(sem) '******Das********** Dim diacum As Integer = Val(Mid(Fecha, 1, 2)) Dim diaact As Integer = Val(Mid(Date.Today, 1, 2)) Dim dia As Integer = Math.Abs(diaact - diacum) LblDias.Text = Str(dia) End If End Sub End Class

You might also like