Codigo vb que calcula el número de vocales en una palabra

Solo disponible en BuenasTareas
  • Páginas : 6 (1271 palabras )
  • Descarga(s) : 0
  • Publicado : 25 de febrero de 2012
Leer documento completo
Vista previa del texto
VOCALES
Private Sub cmdOk_Click()
Dim vcadena, vchar As String
Dim X As Integer
Dim i, contA, contE, contI, contO, contU As Integer

contA = 0
contE = 0
contI = 0
contO = 0
contU = 0

If (Me.txtCadena.Text = "") Then
MsgBox ("Ingresa Un Dato")
Me.txtCadena.SetFocus
Else
i = 1

vcadena =Me.txtCadena.Text
X = Len(vcadena) 'obtengo el número de caracteres'
While (i <= X)
vchar = Mid(vcadena, i, 1)
If (vchar = "a" Or vchar = "A") Then
contA = contA + 1
End If
vchar = Mid(vcadena, i, 1)
If (vchar = "e" Or vchar = "E") Then
contE = contE+ 1
End If
vchar = Mid(vcadena, i, 1)
If (vchar = "i" Or vchar = "I") Then
contI = contI + 1
End If
vchar = Mid(vcadena, i, 1)
If (vchar = "o" Or vchar = "O") Then
contO = contO + 1
End If
vchar = Mid(vcadena, i, 1)If (vchar = "u" Or vchar = "U") Then
contU = contU + 1
End If
i = i + 1
Wend

Me.lblA.Caption = (" Hay " + Str(contA) + " A's")
Me.lblE.Caption = (" Hay " + Str(contE) + " E's")
Me.lblI.Caption = (" Hay " + Str(contI) + " I's")
Me.lblO.Caption = (" Hay " + Str(contO) + " O's")Me.lblU.Caption = (" Hay " + Str(contU) + " U's")
Me.cmdLImpiar.Visible = True
End If
End Sub

Private Sub cmdSalir_Click()
Me.Hide
End Sub

ARREGLOS SUMA
Private Sub cmdOk_Click()
Dim c(5) As Integer
Dim i As Integer
i = 0
While (i < 5)
c(i) = a(i) + b(i)
i = i + 1
Wend
Me.txtSalida.Text = Str(c(0)) + Str(c(1)) + Str(c(2)) +Str(c(3)) + Str(c(4))
Me.txtSalida.Visible = True
End Sub

Private Sub cmdSalir_Click()
Me.Hide
End Sub

Private Sub Form_Load()
Dim i As Integer
i = 0
While (i < 5)
a(i) = Val(InputBox("Dame el dato " + Str(i + 1) + " del primer arreglo", "Entrada"))
i = i + 1
Wend

i = 0
While (i < 5)
b(i) = Val(InputBox("Dameel dato " + Str(i + 1) + " del segundo arreglo", "Entrada"))
i = i + 1
Wend

Me.txtArre1.Locked = True
Me.txtArre1.Locked = True
Me.txtArre1.Text = Str(a(0)) + Str(a(1)) + Str(a(2)) + Str(a(3)) + Str(a(4))
Me.txtArre2.Text = Str(b(0)) + Str(b(1)) + Str(b(2)) + Str(b(3)) + Str(b(4))
End Sub

SUMA Y RESTA DE DOS NUMEROS
Private Sub cmdOk_Click()
If (Me.optSuma.Value = True)Then
If (Me.txtDato1.Text = "") Or (Me.txtDato2.Text = "") Then
MsgBox ("Ingresa un dato")
If (Me.txtDato1.Text = "") Then
Me.txtDato1.SetFocus
Else
Me.txtDato2.SetFocus
End If
Else
Me.cmdLImpiar.Visible = True
Me.lblResul.Caption = "Resultado"
Me.txtResul.Text = Str(Val(Me.txtDato1.Text) +Val(Me.txtDato2.Text))
Me.txtResul.Visible = True
End If
End If

If (Me.OptResta.Value = True) Then
If (Me.txtDato1.Text = "") Or (Me.txtDato2.Text = "") Then
MsgBox ("Ingresa un dato")
If (Me.txtDato1.Text = "") Then
Me.txtDato1.SetFocus
Else
Me.txtDato2.SetFocus
End If
Else
Me.cmdLImpiar.Visible = TrueMe.lblResul.Caption = "Resultado"
Me.txtResul.Text = Str(Val(Me.txtDato1.Text) - Val(Me.txtDato2.Text))
Me.txtResul.Visible = True
End If
End If

End Sub
Private Sub cmdSalir_Click()
Me.Hide
End Sub
Private Sub optResta_Click()
Me.lbldato1.Caption = "Minuendo :"
Me.lbldato2.Caption = "Sustraendo :"
Me.lbldato1.Visible = True
Me.lbldato2.Visible = True...
tracking img