Tutoriales de Visual Basic

Introducción

Este programa permite escribir un numero y el te devuelve el nombre del valor escrito.

En el formulario agregamos dos botones (aceptar y salir) y una caja de texto.
Y utilizaremos dos funciones unidades y decenas.



Private function Unidades() As Integer
    select Case Right(txtnumeros.Text, 1)
        Case 1: labresultado.Caption = labresultado.Caption + "Uno"
        Case 2: labresultado.Caption = labresultado.Caption + "Dos"
        Case 3: labresultado.Caption = labresultado.Caption + "Tres"
        Case 4: labresultado.Caption = labresultado.Caption + "Cuatro"
        Case 5: labresultado.Caption = labresultado.Caption + "Cinco"
        Case 6: labresultado.Caption = labresultado.Caption + "Seis"
        Case 7: labresultado.Caption = labresultado.Caption + "Siete"
        Case 8: labresultado.Caption = labresultado.Caption + "Ocho"
        Case 9: labresultado.Caption = labresultado.Caption + "Nueve"
    end Select
end function

Private function Decenas() As Integer select Case Left(txtnumeros.Text, 1) Case 1: labresultado.Caption = "Dieci " Case 2: labresultado.Caption = "Veinti " Case 3: labresultado.Caption = "Treinta " Case 4: labresultado.Caption = "Cuarenta " Case 5: labresultado.Caption = "Cincuenta " Case 6: labresultado.Caption = "Sesenta " Case 7: labresultado.Caption = "Setenta " Case 8: labresultado.Caption = "Ochenta " Case 9: labresultado.Caption = "Noventa " end Select end function


En el botón aceptar:



Private sub cmmaceptar_Click()
    if IsNumeric(txtnumeros.Text) Then
        select Case txtnumeros.Text
            Case 0:  labresultado.Caption = "Cero"
            Case 11: labresultado.Caption = "Once"
            Case 12: labresultado.Caption = "Doce"
            Case 13: labresultado.Caption = "Trece"
            Case 14: labresultado.Caption = "Catorce"
            Case 15: labresultado.Caption = "Quince"
            Case 10: labresultado.Caption = "Diez"
            Case 20: labresultado.Caption = "Veinte"
            Case 30: labresultado.Caption = "Treinta"
            Case 40: labresultado.Caption = "Cuarenta"
            Case 50: labresultado.Caption = "Cincuenta"
            Case 60: labresultado.Caption = "Sesenta"
            Case 70: labresultado.Caption = "Setenta"
            Case 80: labresultado.Caption = "Ochenta"
            Case 90: labresultado.Caption = "Noventa"
        end Select
        if Right(txtnumeros, 1) = 0 Or (txtnumeros.Text >= 11 And 
txtnumeros.Text <= 15) Then
            
        else
            if Len(txtnumeros.Text) = 1 Or 
Left(txtnumeros.Text, 1) = 0 Then
                labresultado.Caption = ""
                Call Unidades
            else
                Call Decenas
                Call Unidades
            end If
        end If
    else
        MsgBox ("Escribe solo numeros")
    end If
    
    txtnumeros.Text = ""
    txtnumeros.SetFocus
end sub


En el botón salir:



Private sub cmmsalir_Click()
    Unload Me
end sub


Autor: Gamaliel M. DescargarDescargar

Comentarios en "Nombre del número en visual"

Table 'programa_programas.t_comentarios' doesn't exist