Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: E N T E R en Febrero 15, 2013, 01:48:23 pm
-
Tengo este codigo que alinea los numero de hacia la derecha pero al llegar a mas de 1.000.000 ("un millon") me tira un Error 5 en tiempo de ejecucion.
Llamada a procedimiento o argumento no válido
CODIGO
Function AlignRight(NData, CFormat) As String
If NData > 0 Then
AlignRight = Format(NData, CFormat)
AlignRight = Space(Len(CFormat) - Len(AlignRight)) + AlignRight
Else
AlignRight = Format(NData, CFormat)
AlignRight = Space(Len(CFormat) - 1) + "0"
End If
End Function
Private Sub Command1_Click()
Me.Print AlignRight("10", "##,###0")
Me.Print AlignRight("100", "##,###0")
Me.Print AlignRight("1000", "##,###0")
Me.Print AlignRight("10000", "##,###0")
Me.Print AlignRight("100000", "##,###0")
Me.Print AlignRight("1000000", "##,###0")
End Sub
EJEMPLO
(http://snag.gy/IbvHv.jpg)
-
Bueno la Solucion es que pongas mas #
Me.Print AlignRight("1000000", "#######,###0")
-
Gracias amigo, me sirvio.
También hice este método mas resumido.
Public Function xRight(xNumero) As String
xRight = Format(Format(xNumero, "##,###0"), "@@@@@@@@@@@@@@")
End Function
Private Sub Form_Load()
Me.Print xRight(10000000000)
End Sub
No se cual conviene mas usar pero esta funcionando muy bien para lo que quiero.
Saludos...