logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 Custom Data Types in VB6, Fast String Implementation

Posted on
3/2/2004
Author:
Brian Yule
Email:
Not Shown
Applies To OS:
NT, 9x, 2000
Product:
6



By Brian Yule (byule at PembrokeTechnology.com)
Download the project (20 kb)

It's long been said that VB is not good at custom data type handling. This code provides a framework for building your own data types in VB6. This project cotains the concept of using memory to hold data and to wrap the data held as a data type. In addition, the code comes with your own implementation of Integer, Long, Byte, ByteArray, String and StringBuilder (similar to the idea used for StringBuilder class in .NET).

Because these new data types are objects you can add whatever methods and property you want. For instance, you can replicate whatever .NET offers. In addition, it is possible to create Data Types that are not even available in VB, like an Unsigned Int or whatever else.

So just for fun, I compared concatenation performance of the standard VB String Data Type versus the clsString custom string data type and the StringBuilder. Amazingly enough, the clsString class on average 50 to 80 times faster (that's x * 80) than the regular string class. The StringBuilder class gets progressively faster as the string size gets bigger. For instance, when the string is concatenated 5000 times, it is 75 times faster than the String type. When the string is concatenated 50,000 times, the StringBuilder is nearly 1200 times faster (yep, that's x * 1200). In fact, the performance of the StringBuilder class is nearly identical to that of the StringBuilder class in .NET, which is considered the fastest thing since the Road Runner cartoon.

Concatenations (number of times) 5000 10000 25000 50000
Standard VB String Data Type (seconds) 1.171875 10.26563 85.6875 355.4375
Custom String Data Type (seconds) 0.015625 0.125 1.4375 6.078125
StringBuilder class (seconds) 0.015625 0.046875 0.109375 0.296875





clsString Times faster 75 82 59 58
StringBuilder Times faster 75 219 783 1197


Download the project (20 kb)





Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word:
 



Comments
#1. By Fisnik Fondaj. Posted on 7/9/2007 7:15:22 AM
hello!
I need help about ComboBoxes in VB6.
I have a probleam to take two coolums in acombo box, and to see the whole values in the combo!
Thanks for your help!

#2. By gimhana. Posted on 9/23/2007 4:25:28 AM
hello!
i need help about if ...then...elseif statements in vb6.0
i have a problem in use of that statement

#3. By Narayanan. Posted on 2/11/2008 5:30:01 AM
Hi,
I need 1 help.While i am updating a string value which is more than 200 chars in VB6,using Oracle 10g as back end i am receiving an error:- Error! Unknown adodc error ORA 01461 can bind a LONG value only for insert into a LONG column.I have set data type as varchar2(4000) in Oracle.I have been passing value as a String through VB6.
Pls help me in this matter.

#4. By mani sadeghpour. Posted on 7/10/2008 9:04:04 AM
hello
I need help about support a large number of number in vb to complete the program about amicable numbers please sent me back the sorce of creating large number in vb
thank you
mani sadeghpour from iran

#5. By Van. Posted on 12/3/2009 4:32:42 AM
Thanks very much, the strings I was building were taking a looooong time without this!