|
-
Mar 9th, 2006, 11:54 AM
#1
New Member
Re: How can I span faster?
Hi,
that's easy to solve.
The longer the text (sSpan) the longer the & to sSpan.
Make chunks and you will see its much faster.
e.g.
By Jeanie
-
Mar 9th, 2006, 03:04 PM
#2
Thread Starter
New Member
Re: How can I span faster?
It has to be in chunks of 76 characters though.
-
Mar 10th, 2006, 03:08 AM
#3
Re: How can I span faster?
It keeps getting slower because each time you handle strings, you copy memory from place to another. So when the string gets longer it just keeps getting slower as more memory is required to be moved around.
Easiest method to go around this problem is to first reserve the required amount of memory using String$ and then doing Mid$(dest) = Mid$(source) and you'll be copying the data much faster. You just have to precalculate the final size of the string beforehand, which is as simple as
NewLength = ((Len(source) \ 76) * 78) + (Len(source) Mod 76)
Yet another method is to copy the data to byte array and handle the copying that way.
The most ultimate way you can use in VB6 is to change SAFEARRAYHEADER of an integer array to point to the string and copy data from an integer array to another. Search for SisicM to find a InStrCount function by me that uses this method if interested.
Pretty much the same technique is used in all of these, precalculate the final size and copy data directly to there.
-
Mar 10th, 2006, 10:43 AM
#4
Thread Starter
New Member
Re: How can I span faster?
Ok, first off, thanks for the reply.
Secondly, I tried the first method you suggested, but it doesn't seem to be actually moving the data from one string to the next. Here is what I came up with:
VB Code:
NewLength = ((Len(sLong) \ 76) * 78) + (Len(sLong) Mod 76)
Dim sSpan As String * NewLength
For i = 1 To NewLength Step lLineLength
' collect 75 chars and add a vbCrLf
Mid$(sSpan, i, 76) = Mid$(sLong, i, 74)
sSpan = sSpan + vbCrLf
Next i
sSpan is supposed to be the final string, and sLong is where it needs to be copied from, but it isn't actually copying it. Any suggestions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|