Ver Mensaje Individual
  #72 (permalink)  
Antiguo 30/05/2005, 16:26
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 20 años, 11 meses
Puntos: 5
De acuerdo Super Fast String Concatenation

Función para concatenar miles de variables en una sola y rápidamente...
normalmente se utiliza:

for I = 1 to 10000
mivariable = mivariable & I
next

y esto nos arroja timeout en nuestras páginas de asp y además es super lento

Esta clase reemplaza eso y lo hace super rápido (segundos)

aquí les va:

Código:
Class StringBuilder
	Private Sub Class_Initialize()
		growthRate = 50
		itemCount = 0
		ReDim arr(growthRate)
	End Sub
	
	Public Sub Append(ByVal strValue)
		If itemCount > UBound(arr) Then
			ReDim Preserve arr(UBound(arr) + growthRate)
		End If
	
		arr(itemCount) = strValue
		itemCount = itemCount + 1
	End Sub
	
	Public Function ToString() 
		ToString = Join(arr, "")
	End Function
End Class
UTILIZACIÓN:

Código:
Dim objBuilder, i
Set objBuilder = new StringBuilder

For i = 0 To 5000
variable = "este es el número: " & i & "<br>" & vbcrlf
objBuilder.Append(variable) Next Response.Write objBuilder.ToString()

está super cool esta función...
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.