Results for "Author: vesa piittinen"
This code seeks from the end of a byte array trying to find a matching text. Why? Well, handling byte arrays is much faster than handling strings. So, if you needed to parse data real fast and a lot, it would be benefical to do it using a byte array instead of a string. My starting point to this was rather simple: do the search faster than InStr and InStrRev. Beating the latter was easy: InStrRev isn't of the fastest build-in functions in VB. With InStr I had to taste half of a defeat: it just is superb when it can search in BinaryCompare. But, what if we wanted to do TextCompare? Well, there InBArr and InBArrRev beat real badly both InStr and InStrRev! Anyways, I hope somebody finds this submission helpful. I'm sorry I didn't comment the code as well as I could/should have, but I hope it doesn't matter as the code should be rather flawless on what it does :) Comments and votes welcome, as always!
The main purpose of this code is to show an extremely fast method for displaying graphics. The progress bar is done as an OCX, which displays an 8-bit image done in to a byte array which is then made an API image and BitBlt'd to the custom control. It is about as fast you can get. The project includes a string.tlb Type Library which has an assembly optimized CopyMemory API replacement (I hope these are allowed here, if not, look for VBSpeed @ Google). The code is fairly commented and should be easy to follow, even as it uses some advanced techniques. It is very fast and it gets even faster when you compile the code! Hope you like it and find it useful for learning :)
This is the coolest Progress Bar control you have seen out there. Includes many nice features. Can do colorfading, text scrolling, borderstyles, can be set vertical...anything you can think of. Besides that, the code is very efficient and fast. A good example on how an ActiveX / OCX is made and what it needs.
A simple demo on how to 1) add many icons to the systray 2) scroll a custom text in the icons. From this example you can learn how to place icon to systray, learn how to use API (BitBlt used), how to convert a graphic to an icon, how to show a properly working popup menu in the systray icon and some other little coding tricks. The code is not optimized for speed, but is fully commented for your reading and learning pleasure. You are free to use this code in your programs and you don't need to mention my name anywhere (though it'd be great if you credited me or my site in your documentation). Vote if you feel so :)
An IRC client I'm making for my own use. At the moment supports IRC protocol near 100%, is fairly stable even though there are bugs to be resolved and includes most of the basic functions required for use. Supports multiple servers & channels with perform & autojoining. Main feature is to create it as easy to use as possible. I'm looking for any additional help people could provide, I really need proof-reading of the code and bug testing, with additional suggestions - any help will do. You can contact me through my site merri.net or at VBForums Project Request area. You are free to use the base IRC core in your own program, but you must create the looks completely by yourself. The code is free for use, the design is not. I don't want to see any cheap copies out there ;) Thanks to anyone who is willing to help!
This is quite a rare need, but here is a very fast solution for finding out whether there is a duplicate of any specific character within a string. Some people use InStr or InStrB as a solution for finding out a character duplicate, but the drawback is that InStr gets slow very fast if the first few characters are not duplicate characters. Also, if there are no duplicates then InStr loops the whole string the amount of length of the string, which can mean hundreds of times at worst case scenarios. The project provides two functions: HasDuplicates and HasDuplicatesM, the latter is class wrapped. The first one is a straightforward InStrB version. The second uses bitmasking in a Long array as well as safe array tricks to get Integer array access to the characters of the given string. Both functions return a character position of the first duplicate they find, however the results between the functions are always different, because InStrB version returns the first character while the safe array version returns the duplicate. InStrB version can be changed to work the same way. This code was requested at VBForums, I don't know why, but I made it anyway. The code should have enough comments for people to learn some advanced VB6 memory tricks.
I've seen many ways to check whether a certain control index exists in a control array, where all indexes are not filled. For example, you could have a control array of labels with indexes 0, 1 & 3. I guess one of the most common ways to check for this is to use On Error, but I've always found resorting to rising errors a bad habit to do. A much better another alternative is to loop through the control array using For Each and check for the Index property, but even this becomes a bit silly if you know the index you want to check for and loop the entire control array just to check if it is there or not. The solution: VarType() VarType returns the variable type of default property of a control, ie. VarType(MyLabels(1)) returns 8 (vbString), from Caption property. What makes this usable for sniffing for valid index is that VarType returns 9 (vbObject) for invalid indexes! There is no control that returns an object in their default property, making this a perfectly safe method to check if an index exists or not.
These functions convert hex strings from/to byte arrays. A quick introduction to each: HexStringToBytes_A1: one of the most common ways to turn hex string to byte string using "&H" string conversion to a byte value. HexStringToBytes_A2: an optimized version of A1, grabs bigger values in one go and reduces amount of strings created. HexStringToBytes_A1: fills byte array using AscW & MidB$ HexStringToBytes_A2: same as before, but uses the passed string as a buffer instead just for comparison. Slower as creates more strings than A1. HexStringToBytes_C1: uses Windows CryptStringToBinary API. HexStringToBytes_S1: uses a lot of advanced VB6 tricks to achieve the greatest speed. API just can't compete with this one. HexStringToBytes_F1: uses advanced VB6 tricks like last one, but allows for any formatting in the passed hex string (such as spaces, line changes or anything else – simply looks for any valid hex pairs it can find). Shortly put: the C1 and F1 functions can parse "41 00 42 00 43 00", with formatting. The others only accept "410042004300", no formatting. Those hex strings would convert into a byte array: B(0) = 65 B(1) = 0 B(2) = 66 B(3) = 0 B(4) = 67 B(5) = 0 Or "ABC" as a string (Dim S As String: S = B). There are also functions working the other way around, BytesToHexString_C1 & BytesToHexString_F1. C1 is a version using CryptBinaryToString API while F1 is an optimized function that allows for custom output formatting! You can have any kind of formatting: none at all, just spaces between each hex pair, HTML, XML, C notation, JSON... use your imagination. Not only that, the F1 version is way faster than the C1 version with the exact same output! The following tricks are generally used for speed in the S1 and F1 functions: Safe arrays: VB6 stores arrays internally as safe arrays. The function creates "fake" Long and Integer arrays. Integer array for accessing the string data (1 character = 2 bytes = Integer) and a Long array for memory manipulation (PutMem4 & GetMem4 replacement) as well as saving the decoded hex string to the byte array. SysAllocStringByteLen: this API creates a BSTR and it does that very fast, especially if pointer is set to 0, in which case you get any free point from memory. That memory is not touched in any way except for setting up the minimal BSTR structure information (4 bytes string length & 2 bytes null terminator). This memory is not given to a string however! Instead it is given to the resulting Byte array. Why? It saves an unnecessary step of nullifying all the bytes that are reserved, and this always happens if you just ReDim an array. Long is the fastest datatype in VB6 in current processors. This is why a Long array is used to store the new bytes into the Byte array instead of just using it directly. Summa summarum: these functions should give good knowledge for anyone who wants to understand how memory can be handled so that you achieve better performance code in VB6. It isn't pretty though.
There is a problem with most of the CSV parsers/readers out there: they do not follow RFC4180. Most handle quotes and comma delimiters properly, but can't handle line changes within quotes. Additionally most of the codes are on the slow side, practically dying if you happen to have a CSV file that goes a few megabytes in size. This procedure is somewhat optimized for speed so a few megabytes is a no-issue. Detailed information at http://www.vbforums.com/showthread.php?t=604031
This is a self-contained timer class module. This means there is only one class module required, thus no external module file. This has been achieved by adapting SelfCallback code by Paul Caton and LaVolpe, but this time around I've simplified the code as the requirements in this kind of a class are minimal. Thus the code is much shorter and may give a better picture for some people on what is required for SelfCallback. Naturally the timer is IDE safe so you can hit pause and stop without a worry of crashing. **** Update 1.1: the code is now shorter and faster, code adapter from Paul's Universal DLL Caller. Now all code of interest is in Private_Start and Private_Stop.
Unicode textbox and listbox. On these controls I've attempted to mimic the behavior and features of the native controls, but also give much more power by implementing much more of the native features provided by the Windows API. Despite the focus being on implementing Unicode aware versions of the native controls, you can find much more power than just the Unicode. **** These Release Candidates are released outside the main UniControls release for bug testing and comments - thus I'd like to hear of any problems or oddness you may encounter with the controls so that I can fix them before compiling the main UniControls release (thus the next UniControls release is to be considered stable). **** UniControls main release: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=69738&lngWId=1
This is the coolest Progress Bar control you have seen out there. Includes many nice features. Can do colorfading, text scrolling, borderstyles, can be set vertical...anything you can think of. Besides that, the code is very efficient and fast. A good example on how an ActiveX / OCX is made and what it needs.
This is a new cool progress bar control. I've been doing it two days, based partly on my previos progress bar (I submitted it now already as I'm doing my military service and are therefore limited in time). Though this one is different by looks and is also improved by speed. At the moment the control is not complete, there are properties that are not yet finished. Despite this fact, the control does work. I wish you like that control and that it's customizable :) You can change borders' style, all the colors (15 different), direction (right, up, left, down), set text on it, custom done text and so on.
The best progress bar on PSC: it's fast, it looks cool and it's stable. All you need when it comes to showing a progress. Includes: 1) colors and colorfades! 2) use any font, make it appears as you want 3) you can use seven different borderstyles 4) make the bar grow up, down, right or left 5) Blending (changes color opacity or CosSin mode makes weird colors!) 6) Set the caption just like you want it to be 7) ManualRefresh for optimal usage: if you change colors a lot or do other big changes at a time, you might want to refresh the bar only when you wish 8) Min, Max and Value as big or small as you want 9) You can change parent easily with SetParent 10) enough events: make it a command button as well! 11) clear, optimized code: learn how things can be done fast in VB. Also great example on how to make an ActiveX control with VB. If you like it, please vote & rate :)
Enhanced label with Unicode support. Copy UniLabel.ctl and UniLabel.ctx to your project's path and add the control into the project! Thanks to Paul Caton (SelfSub), Ralph Eastwood (for fixing SelfSub 2.1 bug) and Zhu Jin Yong (for UnicodeStrings.res and sample code to use it). Read special_features.txt for more information! | UPDATE 2.2 - 2007-11-19 - SelfSub fixed to version released by LaVolpe, thus finally fixing the crash issues! | UPDATE 2.3 - 2007-12-05 - BackStyle works now, some additional font properties added to ease font manipulation.
This code seeks from the end of a byte array trying to find a matching text. Why? Well, handling byte arrays is much faster than handling strings. So, if you needed to parse data real fast and a lot, it would be benefical to do it using a byte array instead of a string. My starting point to this was rather simple: do the search faster than InStr and InStrRev. Beating the latter was easy: InStrRev isn't of the fastest build-in functions in VB. With InStr I had to taste half of a defeat: it just is superb when it can search in BinaryCompare. But, what if we wanted to do TextCompare? Well, there InBArr and InBArrRev beat real badly both InStr and InStrRev! Anyways, I hope somebody finds this submission helpful. I'm sorry I didn't comment the code as well as I could/should have, but I hope it doesn't matter as the code should be rather flawless on what it does :) Comments and votes welcome, as always!
This code makes it possible to search byte arrays. You can search in ANSI (textfiles) or Unicode mode (native VB strings) and the function supports vbTextCompare. The search keyword is passed as a normal string for ease of use. *** This function is somewhat a proof that you can make fast stuff with native VB6 code: with a proper search algorithm even the super fast InStr can be beaten in binary compare! The function uses Boyer-Moore algorithm as its base of searching when keyword is longer than two characters. The function will perform faster if the keyword doesn't change often, as its prosessing speed is heavily based on intelligent keyword indexing. The function will also easily beat InStr when searching for a long keyword within a very long text. The code doesn't use API or TLB to help; it would be possible to increase the speed even further with the help of API and TLB. I didn't want to confuse with the use of those methods. *** The function code is commented so it should be possible to follow how it works. I've spent some time to figure out this function with this much performance, so I hope to get votes - the code should be very useful to anyone who wants to search stuff FAST :)
These functions perform a search like InStr within a byte array. Accessing byte arrays is much faster than accessing strings, but there aren't many tools provided in VB to handle the arrays. So here you have something: InBArr and InBArrRev, which can search byte arrays with a string keyword in both Unicode and ANSI modes. *** NOTE: you probably don't have a file named C:\hotfix.txt, so you have to edit Form_Load so you can try it. *** Votes welcome :)
This is a Label replacement control that gives you some limited CSS features (BorderRadius, Border, Margin, Padding, Opacity) and Unicode support. Rounded corners are limited because they are implemented using Windows API RoundRect which doesn't give the nicest results in every case.For a more complete description visit VBForums thread: http://www.vbforums.com/showthread.php?t=626737
While I think these TrimNull functions are a bit silly business, I guess they're mostly used due to lack of understanding of Windows API return values or of the file that is being processed, here you can find proper implementations of the LTrim & RTrim equivalents for NULL characters. Instead of InStr of any kind the string is processed as Integer array, without making a new copy of the string. This allows full control over the validation process and thus string is properly parsed from any NULLs at the end or beginning of a string. A test program is included for comparison which shows the bugs in other implementations. Also a bit fuzzy logic RTrimZZ is included: it is fast, but it is mostly dedicated to cases where you expect a buffer full of NULL, except for the actual data at the beginning of the string. The functions are long but fast.