Autor Tema: Mejorar esta funcion  (Leído 2498 veces)

0 Usuarios y 1 Visitante están viendo este tema.

E N T E R

  • Petabyte
  • ******
  • Mensajes: 1062
  • Reputación: +57/-13
  • www.enterpy.com
    • Ver Perfil
    • www.enterpy.com
Mejorar esta funcion
« en: Agosto 12, 2011, 04:47:52 pm »
Lo que quiero es dentro de esta funcion que permita formatear y que tambien pueda quitar el formato.

Código: [Seleccionar]
-

Public Function toMoney(ByVal srcCurr As String) As String
   toMoney = Format(srcCurr, "##,###0")
End Function

Private Sub Text1_Change()
    Text1.Text = toMoney(Text1.Text)
    Text1.SelStart = Len(Text1.Text)
End Sub


Private Sub Command1_Click()
    Text1.Text = toMoney(Text1.Text, M)
End Sub

-

ahi en el comand1 por ejemplo le puse un, M o sea si pongo M que formatee a millar si pongo ,Q entonces que quite el millar.
CIBER GOOGLE - CONCEPCIÓN PARAGUAY
www.enterpy.com
Primera regla de la programacion, para que vas a hacerlo complicado si lo puedes hacer sencillo

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Mejorar esta funcion
« Respuesta #1 en: Agosto 12, 2011, 04:55:07 pm »
Código: [Seleccionar]
Public Function toMoney(ByVal srcCurr As String, FormatM as Boolean) As String
if FormatM then
   toMoney = Format(srcCurr, "##,###0")
else
   toMoney = Format(srcCurr, "###0")
endif
End Function

Text1.Text = toMoney(Text1.Text, True) 'Devolver con millar
Text1.Text = toMoney(Text1.Text, False) 'Devolver sin millar

Me encuentras en YAcosta.com

E N T E R

  • Petabyte
  • ******
  • Mensajes: 1062
  • Reputación: +57/-13
  • www.enterpy.com
    • Ver Perfil
    • www.enterpy.com
Re:Mejorar esta funcion
« Respuesta #2 en: Agosto 12, 2011, 06:36:36 pm »
Impecable, funciona de lujo...

Gracias...
CIBER GOOGLE - CONCEPCIÓN PARAGUAY
www.enterpy.com
Primera regla de la programacion, para que vas a hacerlo complicado si lo puedes hacer sencillo