Sei sulla pagina 1di 8

Sumante fcil. Creamos un form y en el colocamos un label (Label1).

Ahora arrastramos el componente Timer a nuestro form, y veremos que se coloca un simbolo abajo de nuestro ambiente de diseo.

Ahora le damos dos click al simbolo del Timer arrastrado en el paso anterior y dentro de el escribimos el siguiente codigo.

Label1.Text = Date.Now.ToLongTimeString Ahora en las propiedades del Timer, colocamos el valor TRUE a la propiedad Enabled, y listo a correrlo.

About these ads

Public Function Num2Text(ByVal value As Double) As String Select Case value Case 0 : Num2Text = "CERO" Case 1 : Num2Text = "UN" Case 2 : Num2Text = "DOS" Case 3 : Num2Text = "TRES" Case 4 : Num2Text = "CUATRO" Case 5 : Num2Text = "CINCO" Case 6 : Num2Text = "SEIS" Case 7 : Num2Text = "SIETE" Case 8 : Num2Text = "OCHO" Case 9 : Num2Text = "NUEVE" Case 10 : Num2Text = "DIEZ" Case 11 : Num2Text = "ONCE" Case 12 : Num2Text = "DOCE" Case 13 : Num2Text = "TRECE" Case 14 : Num2Text = "CATORCE" Case 15 : Num2Text = "QUINCE" Case Is < 20 : Num2Text = "DIECI" & Num2Text(value - 10) Case 20 : Num2Text = "VEINTE" Case Is < 30 : Num2Text = "VEINTI" & Num2Text(value - 20) Case 30 : Num2Text = "TREINTA" Case 40 : Num2Text = "CUARENTA" Case 50 : Num2Text = "CINCUENTA" Case 60 : Num2Text = "SESENTA" Case 70 : Num2Text = "SETENTA" Case 80 : Num2Text = "OCHENTA" Case 90 : Num2Text = "NOVENTA" Case Is < 100 : Num2Text = Num2Text(Int(value \ 10) * 10) & " Y " & Num2Text(value Mod 10) Case 100 : Num2Text = "CIEN" Case Is < 200 : Num2Text = "CIENTO " & Num2Text(value - 100) Case 200, 300, 400, 600, 800 : Num2Text = Num2Text(Int(value \ 100)) & "CIENTOS" Case 500 : Num2Text = "QUINIENTOS" Case 700 : Num2Text = "SETECIENTOS" Case 900 : Num2Text = "NOVECIENTOS" Case Is < 1000 : Num2Text = Num2Text(Int(value \ 100) * 100) & " " & Num2Text(value Mod 100) Case 1000 : Num2Text = "MIL" Case Is < 2000 : Num2Text = "MIL " & Num2Text(value Mod 1000) Case Is < 1000000 : Num2Text = Num2Text(Int(value \ 1000)) & " MIL"

If value Mod 1000 Then Num2Text = Num2Text & " " & Num2Text(value Mod1000) Case 1000000 : Num2Text = "UN MILLON" Case Is < 2000000 : Num2Text = "UN MILLON " & Num2Text(value Mod 1000000) Case Is < 1000000000000.0# : Num2Text = Num2Text(Int(value / 1000000)) & " MILLONES " If (value - Int(value / 1000000) * 1000000) Then Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000) * 1000000) Case 1000000000000.0# : Num2Text = "UN BILLON" Case Is < 2000000000000.0# : Num2Text = "UN BILLON " & Num2Text(value -Int(value / 1000000000000.0#) * 1000000000000.0#) Case Else : Num2Text = Num2Text(Int(value / 1000000000000.0#)) & " BILLONES" If (value - Int(value / 1000000000000.0#) * 1000000000000.0#) ThenNum2Text = Num2Text & " " & Num2Text(value Int(value / 1000000000000.0#) * 1000000000000.0#) End Select End Function

Private Sub txtmon_LostFocus() Dim sValor As String, siValor As Single Dim i, r As Single sValor = txtmon txtmon = Val(Replace(sValor, ",", ".")) i = Int(Val(txtmon)) r = CInt((txtmon - i) * 100) Num2Text (Val(txtmon)) If r > 0 Then txtmonl = txtmonl.Text & " CON " + Num2Text(r) + " CENTIMOS" End If txtmon = Format(txtmon, "currency") End Sub Public Function Num2Text(ByVal value As Double) As String

value = Int(value) Select Case value Case 0: Num2Text = "CERO" Case 1: Num2Text = "UN" Case 2: Num2Text = "DOS" Case 3: Num2Text = "TRES" Case 4: Num2Text = "CUATRO" Case 5: Num2Text = "CINCO" Case 6: Num2Text = "SEIS" Case 7: Num2Text = "SIETE" Case 8: Num2Text = "OCHO" Case 9: Num2Text = "NUEVE" Case 10: Num2Text = "DIEZ" Case 11: Num2Text = "ONCE" Case 12: Num2Text = "DOCE" Case 13: Num2Text = "TRECE" Case 14: Num2Text = "CATORCE" Case 15: Num2Text = "QUINCE" Case Is < 20: Num2Text = "DIECI" & Num2Text(value - 10) Case 20: Num2Text = "VEINTE" Case Is < 30: Num2Text = "VEINTI" & Num2Text(value - 20) Case 30: Num2Text = "TREINTA" Case 40: Num2Text = "CUARENTA" Case 50: Num2Text = "CINCUENTA" Case 60: Num2Text = "SESENTA" Case 70: Num2Text = "SETENTA" Case 80: Num2Text = "OCHENTA"

Case 90: Num2Text = "NOVENTA" Case Is < 100: Num2Text = Num2Text(Int(value \ 10) * 10) & " Y " & Num2Text(value Mod 10) Case 100: Num2Text = "CIEN" Case Is < 200: Num2Text = "CIENTO " & Num2Text(value - 100) Case 200, 300, 400, 600, 800: Num2Text = Num2Text(Int(value \ 100)) & "CIENTOS" Case 500: Num2Text = "QUINIENTOS" Case 700: Num2Text = "SETECIENTOS" Case 900: Num2Text = "NOVECIENTOS" Case Is < 1000: Num2Text = Num2Text(Int(value \ 100) * 100) & " " & Num2Text(value Mod 100) Case 1000: Num2Text = "MIL" Case Is < 2000: Num2Text = "MIL " & Num2Text(value Mod 1000) Case Is < 1000000: Num2Text = Num2Text(Int(value \ 1000)) & " MIL" If value Mod 1000 Then Num2Text = Num2Text & " " & Num2Text(value Mod 1000) Case 1000000: Num2Text = "UN MILLON" Case Is < 2000000: Num2Text = "UN MILLON " & Num2Text(value Mod 1000000) Case Is < 1000000000000#: Num2Text = Num2Text(Int(value / 1000000)) & " MILLONES " If (value - Int(value / 1000000) * 1000000) Then Num2Text = Num2Text & " " & Num2Text(value Int(value / 1000000) * 1000000) Case 1000000000000#: Num2Text = "UN BILLON" Case Is < 2000000000000#: Num2Text = "UN BILLON " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#) Case Else: Num2Text = Num2Text(Int(value / 1000000000000#)) & " BILLONES" If (value - Int(value / 1000000000000#) * 1000000000000#) Then Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#) End Select If value = 1 Then txtmonl = Num2Text + " BOLVAR" Else txtmonl = Num2Text + " BOLVARES"

End If End Function Public Function Letras(Valor As Double) As String Dim Largo As Integer Dim Decimales As Double, strDecimal As String Largo = Len(CStr(Format(CDbl(Valor), "#,###.00"))) Decimales = Mid(CStr(Format(CDbl(Valor), "#,###.00")), Largo - 2) Select Case Decimales Case 0: strDecimal = "00" Case 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9: strDecimal = (Mid(CStr(Decimales), 3, 2)) * 10 Case Is < 100: strDecimal = Mid(CStr(Decimales), 3, 2) End Select Valor = Valor - Decimales Letras = Num2Text(Valor) & " CON " & strDecimal & "/100 NUEVOS SOLES" End Function Public Function Num2Text(ByVal value As Double) As String Select Case Int(value) Case 0: Num2Text = "CERO" Case 1: Num2Text = "UNO" Case 2: Num2Text = "DOS" Case 3: Num2Text = "TRES" Case 4: Num2Text = "CUATRO" Case 5: Num2Text = "CINCO" Case 6: Num2Text = "SEIS" Case 7: Num2Text = "SIETE" Case 8: Num2Text = "OCHO" Case 9: Num2Text = "NUEVE"

Case 10: Num2Text = "DIEZ" Case 11: Num2Text = "ONCE" Case 12: Num2Text = "DOCE" Case 13: Num2Text = "TRECE" Case 14: Num2Text = "CATORCE" Case 15: Num2Text = "QUINCE" Case Is < 20: Num2Text = "DIECI" & Num2Text(value - 10) Case 20: Num2Text = "VEINTE" Case Is < 30: Num2Text = "VEINTI" & Num2Text(value - 20) Case 30: Num2Text = "TREINTA" Case 40: Num2Text = "CUARENTA" Case 50: Num2Text = "CINCUENTA" Case 60: Num2Text = "SESENTA" Case 70: Num2Text = "SETENTA" Case 80: Num2Text = "OCHENTA" Case 90: Num2Text = "NOVENTA" Case Is < 100: Num2Text = Num2Text(Int(value \ 10) * 10) & " Y " & Num2Text(value Mod 10) Case 100: Num2Text = "CIEN" Case Is < 200: Num2Text = "CIENTO " & Num2Text(value - 100) Case 200, 300, 400, 600, 800: Num2Text = Num2Text(Int(value \ 100)) & "CIENTOS" Case 500: Num2Text = "QUINIENTOS" Case 700: Num2Text = "SETECIENTOS" Case 900: Num2Text = "NOVECIENTOS" Case Is < 1000: Num2Text = Num2Text(Int(value \ 100) * 100) & " " & Num2Text(value Mod 100) Case 1000: Num2Text = "MIL" Case Is < 2000: Num2Text = "MIL " & Num2Text(value Mod 1000) Case Is < 1000000: Num2Text = Num2Text(Int(value \ 1000)) & " MIL"

If value Mod 1000 Then Num2Text = Num2Text & " " & Num2Text(value Mod 1000) Case 1000000: Num2Text = "UN MILLON" Case Is < 2000000: Num2Text = "UN MILLON " & Num2Text(value Mod 1000000) Case Is < 1000000000000#: Num2Text = Num2Text(Int(value / 1000000)) & " MILLONES " If (value - Int(value / 1000000) * 1000000) Then Num2Text = Num2Text & " " & Num2Text(value Int(value / 1000000) * 1000000) Case 1000000000000#: Num2Text = "UN BILLON" Case Is < 2000000000000#: Num2Text = "UN BILLON " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#) Case Else: Num2Text = Num2Text(Int(value / 1000000000000#)) & " BILLONES" If (value - Int(value / 1000000000000#) * 1000000000000#) Then Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000000000#) * 1000000000000#) End Select End Function

Potrebbero piacerti anche