Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Cantidad=GetWordCount (Thisform.txtTexto.

value)
lcCodigo=""
FOR I=1 TO cantidad
lcCodigo=lcCodigo+LEFT(GETWORDNUM(Thisform.txtTexto.value,I),1)
ENDFOR
Dim fechaSeleccionada as Date, edad as integer
fechaSeleccionada = me.DateTimePicker1.Value()
edad = DateDiff (DateInterval.Year, fechaSeleccionada, Date.Today)
DECLARE @Nombre VARCHAR(100),@Apellido VARCHAR(100),@Fecha DATETIME,@Codigo VARC
HAR(100),@Id INT
SET @Nombre = 'Juan David'
SET @Apellido = 'Torres Vaquez'
SET @Fecha = GETDATE()

SELECT @Codigo=CAST((SUBSTRING(@Nombre,1,1)+SUBSTRING(@Apellido,1,1)++CONVERT(VA
RCHAR(10),@Fecha,112)) AS VARCHAR(100))
SELECT @id= @@IDENTITY
SELECT @Codigo,@id AS Codigo
Function DosLetras(ByVal texto As String) As String
Dim strVocales As String = "aeiouAEIOU"
Dim strLetras As String = texto.Substring(0,1) 'Tomamos la primera letra del nom
bre
Dim chrLetra As Char
'Obtenemos la primera letra
chrLetra = texto(0)
'Hacemos un barrido en el texto insertado
For i As Short = 1 To texto.Length - 1
'Tomamos una letra para comparar
chrLetra = texto(i)
If strVocales.IndexOf(chrLetra) > -1 Then
'Si es vocal, la adjuntamos a la primera letra y devolvemos el valor
strLetras &= chrLetra
Return strLetras
End If
Next i
'Devolvemos nulo si no se encontr una vocal
Return Nothing
End Function
Public Class Form1
Private strNombre() As String
Private strFecha() As String
Private strIniciales As String
Private strFechaConFormato As String
Private strTextoFinal As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Me.VaciarStrings()
Me.VaciarTextos()
End Sub
Private Sub btn_Transformar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_Transformar.Click
Me.VaciarStrings()
strNombre = Split(Me.tb_Nombre.Text.Trim, " ")
strFecha = Split(Replace(Me.mtb_Fecha.Text, "-", "/").Trim, "/")
If strNombre.Length = 4 AndAlso Replace(Replace(Me.mtb_Fecha.Text.Trim,
"/", "-"), "-", "").Length = 8 Then
For Each strX As String In strNombre
strIniciales &= strX.Chars(0).ToString.ToUpper
Next strX
For i As Integer = 0 To strFecha.Length - 1
If i = strFecha.Length - 1 Then
strFechaConFormato = strFecha(i).Trim.Substring(2, 2) & strF
echaConFormato
Else
strFechaConFormato = strFecha(i).Trim & strFechaConFormato
End If
Next i
strTextoFinal = strFechaConFormato & "-" & strIniciales
tb_Final.Text = strTextoFinal
Else
MessageBox.Show("Debe rellenar todos los datos primero." & vbCr & _
"Nombre completo y Fecha de Nacimiento con ao de 4 dgi
tos.", _
"Error.", MessageBoxButtons.OK, MessageBoxIcon.Excla
mation)
End If
End Sub
Private Sub VaciarStrings()
strIniciales = ""
strFechaConFormato = ""
strTextoFinal = ""
End Sub
Private Sub VaciarTextos()
Me.tb_Nombre.Text = String.Empty
Me.mtb_Fecha.Text = String.Empty
Me.tb_Final.Text = String.Empty
End Sub
End Class

You might also like