Quick Search for:  in language:    
want,your,strings,routines,fast,possible,lear
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,011,557. lines
 Jobs: 115. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Locate Database
By Erica Ziegler-Roberts on 6/30


Organize the errors of your programs
By Toni on 6/30


how to open and close access database
By Freebug on 6/29


Click here to see a screenshot of this code!PSC-Browser
By Ralph LONG Metz on 6/29

(Screen Shot)

Click here to see a screenshot of this code!Quadratic Solver 2
By Guillaume Couture-Levesqu e on 6/29

(Screen Shot)

Click here to see a screenshot of this code!Array Example
By Cold Fire on 6/29

(Screen Shot)

Click here to see a screenshot of this code!Reconstructor 3.0
By Peter Scale on 6/29

(Screen Shot)

Click here to see a screenshot of this code!Subtitles Manager
By KarahaNa on 6/29

(Screen Shot)

XPlorer
By ZProse on 6/29


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Learn How To Make VB Handle Strings As Fast As C

Print
Email
 

Submitted on: 5/14/2002 4:11:52 PM
By: Chris_Lucas  
Level: Advanced
User Rating: By 74 Users
Compatibility:VB 5.0, VB 6.0, VB Script, ASP (Active Server Pages) , VBA MS Access, VBA MS Excel

Users have accessed this article 8876 times.
 

(About the author)
 
     If you want your strings routines to be as fast as possible, learn C. If you don't want to learn C use string mapping, its nearly as fast and pure VB. In this article I give you the silver bullet for strings. If strings are bottlenecking your code, I'm your new best friend. I've included a project that attempts to visualize the string for you. It also contains a word count comparision which uses four methods string mapping being the fastest by far (compiled).

 
winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzipto decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
3)Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.


Other 5 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/14/2002 4:15:00 PM:Chris Lucas
If you take the time to read this article, please leave your votes and feedback. Thanks and I hope you find this as useful as I do.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/14/2002 8:32:14 PM:Bnyc77
Great code. I work in field that relies heavily on processing millions of lines of string data, and am always on the lookout for an easy way to write quick code to handle a specific need. This is a great tool for those of us who need string-crunching speed but don't have time to work up a C++ app. Cheers! Five stars for making my life that much easier...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2002 6:29:31 AM:ronniec23
excellent tutorial and I can see a million uses for this code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2002 9:18:25 AM:Adam Musson
Chris, this is excellent and in my opinion is one of the best submissions on PSC. It definitely deserves the award. I can't wait to see your class extending this to VB's other string functions. I for one will use it, and extend it if you miss any out, in my applications. If I do any work on it I'll send you the code. Cheers!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2002 1:58:52 PM:Elias Barbosa
I am impressed. I liked your submission and your prompt response to every request made by the other PSC members that tried your code! You should work at Tech Support, some where! :) I just wanted to see some real world examples. For example, could your code be used to create a Replace function that would work faster than the native VB Replace Function? You got my best vote...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2002 3:38:41 PM:Charles Chadwick
It's refreshing to see things posted in the VB section that aren't "How To Use A List Box - Vote For My Code!" and "LeEt AoL HaCkErZ PrOgGiE!!!". This makes me actually want to start programming in VB again.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2002 9:58:36 PM:Brian Morrison
Great stuff. I have been in the process of writing an application that does a ton of string processing, and am now busy putting this great code to use (already using replacements for mid, right and left, based on this)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/27/2002 2:03:50 PM:Kyle
This is probably the best tool I have encountered on the net. It saved me mad time, and in turn allowed me to do my job faster, which made me more money. I'm all about more money, Chris. 5 stars. Use this, it rocks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/29/2002 3:23:04 PM:J. B.
I'd been trying to find ways to speed up the game I've been making and this looks like it could be useful. This earns you 5 from me. (Not to mention it could be useful in other apps too.)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/26/2002 9:46:44 AM:tibisan
MMMMMAAAANNNNNNNN!!!!! I've lost track on this submission(erased my history, after getting rondomly to this post), and i've searched the site for 2 weeks(not kidding). now i finally step here (by chance, what ironic!) to tell u that a love this code. i'll give my 5g's from all my heart.THANK YOU!!!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/10/2002 2:48:24 PM:Chris Lucas
I've deleted a lot of your feedback in order to keep this page a managable size. I've noticed that this article continues to get a large number of hits and felt this would make things easier on the people just finding their way to the string revolution. Thank you all for all the overwhelming feedback and suggestions.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/21/2003 7:17:14 AM:
Loved your code. Gave you 5 globes. Have some questions, though, regarding your recommendations for use of this idea with concatenation of large strings. I have been messing around with your ideas, but need some assistance. Could you pass me on your email address so that I can be more specific in my request. I know that you are, no doubt, busy, but I can see the benefit already of this code for a large database manipulation system I am doing for my employer. Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/21/2003 4:01:00 AM:
you should compare it with the string to ByteArray method, with is the standard in VB for fast working with strings. Public Function FastWordCount2(strSample As String) As Long Dim i As Long, j As Long Dim TmpB() As Byte TmpB = strSample ' String to bytes For i = 0 To UBound(TmpB) Step 2 If TmpB(i) > 32 Then FastWordCount2 = FastWordCount2 + 1 For j = i + 2 To UBound(TmpB) Step 2 If TmpB(j) <= 32 Then Exit For Next j 'check for code with more than one character, double spaces, CrLf, etc. For j = j To UBound(TmpB) Step 2 If TmpB(j) > 32 Then Exit For Next j i = j End If Next i End Function However, you're method is still 20% faster and dramaticaly faster if the number of words is increasing. It is as fast as the old PEEKL-fuction.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.