Autor
|
Tema: [RETO] Entero a cadena (Leído 8,202 veces)
|
Karcrack
Desconectado
Mensajes: 2.416
Se siente observado ¬¬'
|
 Public Function ItoA05(ByVal lNumb As Long) As String Call VarBstrFromI4(lNumb, 0, 0, ItoA05) End Function
http://www.box.net/shared/51biuct9cd Creo que mas rapido o corto imposible  Saludos 
|
|
|
En línea
|
|
|
|
raul338
Desconectado
Mensajes: 2.633
La sonrisa es la mejor forma de afrontar las cosas
|
Esto se llama perder el tiempo reiventando el casting  Public Function StrRaul01(ByVal Number As Long) As String If Number And &H80000000 Then StrRaul01 = "-" Number = Number * -1 End If If Number = 0 Then StrRaul01 = "0": Exit Function If Number = 1 Then StrRaul01 = "1": Exit Function Dim i As Byte Do While True i = Fix(Number Mod 10) Select Case i Case 1: StrRaul01 = StrRaul01 & "1" Case 2: StrRaul01 = StrRaul01 & "2" Case 3: StrRaul01 = StrRaul01 & "3" Case 4: StrRaul01 = StrRaul01 & "4" Case 5: StrRaul01 = StrRaul01 & "5" Case 6: StrRaul01 = StrRaul01 & "6" Case 7: StrRaul01 = StrRaul01 & "7" Case 8: StrRaul01 = StrRaul01 & "8" Case 9: StrRaul01 = StrRaul01 & "9" Case 0: StrRaul01 = StrRaul01 & "0" End Select Select Case Number Case Is > 10: Number = Number \ 10 Case Is = 10 StrRaul01 = StrRaul01 & "10" GoTo Final Case Is < 10 GoTo Final End Select Loop Final: StrRaul01 = StrReverse(StrRaul01) Dim s As String Dim t As Integer Dim l As Integer t = 1 l = Len(StrRaul01) If l = 1 Then Exit Function For i = 1 To l If Mid$(StrRaul01, i, 1) = "0" Then t = t + 1 Else StrRaul01 = Mid(StrRaul01, t) Exit Function End If Next End Function
Al menos es mas rapido que el primer intento de karcrack xDDDVoy a ver si logro agilizarlo
|
|
« Última modificación: 31 Agosto 2010, 00:46 am por raul338 »
|
En línea
|
|
|
|
BlackZeroX
Wiki
Desconectado
Mensajes: 3.158
I'Love...!¡.
|
. Para mi LeandroA gano!¡.
P.D.: solo postee para decir, Que ojasos el de tu Gallo xP
Dulces Lunas!¡.
|
|
|
En línea
|
The Dark Shadow is my passion.
|
|
|
MCKSys Argentina
|
@Karcrack: Lo de LeandroA es lo que se conoce como "evil type convertion" (lo que salto en el otro post) Por las dudas, pongo el mio, aunque es muy parecido: Private Function ItoA03(lNumb As Long) As String ItoA03 = "" & lNumb End Function
|
|
|
En línea
|
MCKSys Argentina "Si piensas que algo está bien sólo porque todo el mundo lo cree, no estás pensando."
|
|
|
ignorantev1.1
Desconectado
Mensajes: 617
/\ Así acabo cuando quiero programar...
|
Una duda:
Como mido el tiempo?
|
|
|
En línea
|
|
|
|
Psyke1
Wiki
Desconectado
Mensajes: 1.089
|
Una duda:
Como mido el tiempo? Con: cTiming.clso con: Private Declare Function GetTickCount Lib "kernel32" () As Long
DoEvents¡! 
|
|
« Última modificación: 1 Septiembre 2010, 21:35 pm por *PsYkE1* »
|
En línea
|
|
|
|
ignorantev1.1
Desconectado
Mensajes: 617
/\ Así acabo cuando quiero programar...
|
Pues si use el mentado "GetTickCount" pero me da 0, a lo mejor lo estoy haciendo mal, por eso pregunte:
dim x as long x=GetTickCount ****llamo funcion**** msgbox GetTickCount-x
|
|
|
En línea
|
|
|
|
Psyke1
Wiki
Desconectado
Mensajes: 1.089
|
Un ej: Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long Private Sub Form_Load() Dim t1 As Long Dim t2 As Long t1 = GetTickCount '1ª marca 'Call Function t2 = GetTickCount '2ª marca MsgBox t2 - t1 'Resultado = diferencia entre marcas. End Sub
DoEvents¡! 
|
|
|
En línea
|
|
|
|
ignorantev1.1
Desconectado
Mensajes: 617
/\ Así acabo cuando quiero programar...
|
Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long Private Sub Form_Load() Dim t1 As Long Dim t2 As Long t1 = GetTickCount '1ª marca Me.Print StrRaul01(-99999) t2 = GetTickCount '2ª marca MsgBox t2 - t1 'Resultado = diferencia entre marcas. End Sub
Renuncio! siempre me da 0...
|
|
|
En línea
|
|
|
|
Psyke1
Wiki
Desconectado
Mensajes: 1.089
|
Ah, es que es tan poco tiempo que no se aprecia con GetTickCount...  Mira prueba con cTiming.cls : Un ej: Option Explicit Dim tmr As CTiming Private Sub Form_Load() Set tmr = New CTiming tmr.Reset Debug.Print StrRaul01(-99999) MsgBox tmr.Elapsed End Sub
Resultado: 0,28903007248116 Ahora si... DoEvents¡! 
|
|
|
En línea
|
|
|
|
|
|