Results for "Category: String Manipulation"
Fast String Searching & CRC checksum calculation in Visual Basic using pre compiled assembly code and memory mapped file concepts.This code is tested for binary comparison with ANSI code inputs only. UNICODE character input and strings having ligatures are not tested. It is up to the user to test the code with UNICODE/special character input and validate it. This is my first submission to PSC web site and I welcome your feedback and votes.
**UPDATED** A starter project for new people to ASP and Access Databases, this script shows efficient INSERT, UPDATE, DELETE statements with CSS styling and a custom built paging script. Please vote - any feedback welcome.
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.
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.
This Code will help the programmer to insert the image into a Sql Server Database through DataReader in VB.NET
User can Login/Register and then update his/her profile. So Powerfull By Designing & Coding Wise At every step user is briefed that what;s going on and why. Easy to Learn for begginers. I asure after to read this code He/She will not be dependable of any one according to ASP Database
it's supposed to return the next password in a sequence of passwords, not random passwords, or a dictionary attack. it's designed to return case-insensitive alphanumeric passwords, but that can easily be changed, i can't help you do that, it's up to you
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 :)
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.
Saves time by NOT having to download your access database to Compact and Repair then re-upload again.
Used by VB applications that want to lightly (without any additional project references) transform unsafe characters into web-friendly URL Encoded text.
With this you can Read Lines (from a textbox and a string), Set Line Number, Get Line Number, Columns, etc. from a TextBox. This is very usefull, seems n00b but it isn't. Please Vote!!
Return a dataset from an excel spreadsheet using OLE DB and a "named region" as a table
This tutorial explains the ways where you can use DataAdapter directly to manipulate databases instead of writing DML commands.
This demo explains the useful functions of DataTables that help you lot while developing applications. This demo explains how to use a DataTable in various ways.. Like.. - How to initialize a DataTable - How to insert records into databases using a DataTable - How to fetch selected set of rows from a DataTable - Empty the contents of a DataTable - Clear the current structure of the DataTable - Copy rows from one DataTable to another - Use a DataTable's structure to create another - Managing changes done to a DataTable - Updating the changes made in the DataTable to the database - Make calculations on the rows of a DataTable and get results - Ways to add rows to a DataTable - Find whether the primary key column of a DataTable contains a specific value - ..etc
The passwords typed in a textbox can be read even if the * appears. But there is a way to prevent this. This is why i created this code. It prevent users from using programs like Spy to read the password (http://come.to/kobik) if the URL don't change.
Word Processor, similar to Microsoft Word (not as many features though). Different fonts, colors, sizes, tabs, rulers, images, files, find, replace, goto, word count and more. Not finished yet, if people think I should bother finishing it off I'll add undo, redo, autosave, image options and possibly more... Please leave comments. Thanks, Neophyte.
Upload and Download BLOB [files] to an Access Database. Handles any file type. Instructions included for implementation under VS.NET, WinXP, IIS 5.1 and .NET Framework SP2. Includes a class to set database connection dynamically and is almost fully documented. Not a great implementation, but does the job and provides relatively straight forward processes for providing this functionality in your WebApplication. Have Fun :)
This is a program to get the Local weather status with information provided from weather.com It is very simple and not much error proofing but it does teach you opening a webpage for reading, string manipulation and using the timer. This took me about an hour. Note it only works for US zipcodes.
This program read a xml file and stole it in a datagrid with all structure.Is a great program