Results for "Category: String Manipulation"
(PLEASE ALSO LOOK AT VERSION 2.10!)This code is an example of 13 different FX that can be easily implemented to a string. I have put them all together and put in quite a few notes explaining what each FX is doing. As you can see from the screenshot each effect can be modified in certain ways. I have written this so that you can have a better understanding of how computers work. I have tried to avoid using many of the built in functions. Each FX may not be the most efficient way of doing them, but I have done it this way to highlight the internal workings. All FX (apart from Rotate) work at a character at a time. Please send in any comments you may have - Good or Bad - so I can improve on it further. If you have any questions then email me. PLEASE RATE THIS. Thankyou.
This is an update of version 2.00 that I have done today. Because of some complaints of the speed I have added a speed option which includes "Fastest" (but this only works for options 8 to 12 as the others are so fast you cannot see them work!!) I have added a new FX called "Black Hole" where the text dissapears in to, or out of, the centre of the string. There are now 2 Bandits. The new 2nd one cycles through all the characters at the same time, compared to number 1 which did them one at a time. It should be noted that this is also an example of Framed Options; diabling and enabling them and discovering which have been selected by the user. Also in the Speed textbox you can only enter numbers (I got that off here, but hey!) Although I wrote this in VB5, I see no reason why it will not work in ANY of the other versions as it only uses basic commands like MID and MID$. (Although I am not sure when the MID command came in...) Please rate this!! and I would be interested in any comments you may have. Thanx!
This small and very simple sub will format the caption of a Label control if the text is too big to display in the control. The sub will trucate the text and append "..." to the end of the text (indicating to the user that they are not seeing the full text). VB automatically wordwraps the caption of a label if it is too big, however, this results in the caption being truncated only where there is a space. Also, you can see the top of the next line of the caption. Example Make and Model: Cadillac becomes: Make and Model: Cadillac Eldor... I find this extremely useful when I don't know the maximum length of the text the label will contain, or if I don't have enough screen real estate to make the Label big enough. Just pass a label to this sub for formatting.
This code provides an IsNull function like that used in SQL Server. This allows you to check if a variable contains null, and if so return a specific value. This can prevent you from having to write things like iif(not isnull(rst!FieldName), rst!FieldName, ""). For new programmers, especially those working with databases, you will quickly become aware that trying to access a database field that contains a null value often results in the dreaded error #94 - Invalid Use of Null, which means you constantly have to write code to trap for that possibility.
It typewrites any text you choose at any given speed
Simple function to validate string contents. Compares a given string to a list of illegal values and evaluates whether or not it contains any. Very fast and easy. Can also be used as a string search function with a little modification.
How would you like to process a form and insert its data into a database with only a couple of lines of code? With this tutorial I will show you how to process forms and insert data into databases with the least effort.
To move (indent) block of selected text as one, instead of one line at the time by using a TAB key. Just like you can select portion of your code in VB and move it as a block to the right. Use TAB to indent Use Shift+TAB to un-indent UPDATED ON 06/14/02: I've just added the UN-INDENT function as well :)
Quicksort which works by sorting string pointers only instead of the strings themselves. In particular for long strings around 1000 chars there is a 15 times improvement in speed, going up to 100 times for really long strings, and speed is almost indepent of string length; one million strings are sorted in under five seconds. For short strings below 10 chars or so speeds are more or less identical. The screenshot shows the compiled timing.
With the InputBox you cannot distinguish between the cases a:- Cancel clicked b:- nothing entered and OK clicked because in both cases the returned string is a vbNullString There is a simple trick however as is shown here
Use these functions in KeyPress events to format user entries as entry is typed. UCaseKeyPress() converts key pressed to uppercase while LCaseKeyPress() converts key pressed to lowercase.
This is a simple example of converting a string data into a hex formatted (packet) view. This will be mostly usefull when sending and receiving data with/through WinSock! Packet displays data in hex and 'readable' characters like the packet below, which seems to be the text you're reading right at this time! 48 65 6C 6C 6F 2C 0D 0A 0D 0A 54 68 69 73 20 69 Hello,....This.i 73 20 61 6E 20 65 78 61 6D 70 6C 65 20 6F 66 20 s.an.example.of. 63 6F 6E 76 65 72 74 69 6E 67 20 61 20 73 74 72 converting.a.str 69 6E 67 20 64 61 74 61 20 69 6E 74 6F 20 61 20 ing.data.into.a. 68 65 78 20 66 6F 72 6D 61 74 74 65 64 20 28 70 hex.formatted.(p 61 63 6B 65 74 29 20 76 69 65 77 2E 0D 0A 54 68 acket).view...Th 69 73 20 77 69 6C 6C 20 62 65 20 6D 6F 73 74 6C is.will.be.mostl 79 20 75 73 65 66 75 6C 6C 20 77 68 65 6E 20 73 y.usefull.when.s 65 6E 64 69 6E 67 20 61 6E 64 20 72 65 63 65 69 ending.and.recei 76 69 6E 67 20 64 61 74 61 20 77 69 74 68 2F 74 ving.data.with/t 68 72 6F 75 67 68 20 57 69 6E 53 6F 63 6B 21 0D hrough.WinSock!. 0A 0D 0A 50 61 63 6B 65 74 20 64 69 73 70 6C 61 ...Packet.displa 79 73 20 64 61 74 61 20 69 6E 20 68 65 78 20 61 ys.data.in.hex.a 6E 64 20 27 72 65 61 64 61 62 6C 65 27 20 63 68 nd.'readable'.ch 61 72 61 63 74 65 72 73 20 6C 69 6B 65 20 74 68 aracters.like.th 65 20 70 61 63 6B 65 74 20 62 65 6C 6F 77 2C 0D e.packet.below,. 0A 77 68 69 63 68 20 73 65 65 6D 73 20 74 6F 20 .which.seems.to. 62 65 20 74 68 65 20 74 65 78 74 20 79 6F 75 27 be.the.text.you' 72 65 20 72 65 61 64 69 6E 67 20 72 69 67 68 74 re.reading.right 20 61 74 20 74 68 69 73 20 74 69 6D 65 21 .at.this.time!
This Code will Scroll the title of your window(s) like Winamp To the left OR to the right.
This function is to strip all instances of a character out of a string. Its fairly compact and simple. Hope its helpful to someone. :)
Nice feature to help users edit textboxes. The code selects all the existing text when the users focus on the textbox control. This will definitely make your application more user friendly. Please Vote!!!
Makes Twisted Text, Kinda Like Scrambled
I needed a routine to display the difference between two dates in year month day format. I found a couple here on pcs and another on a different site. Here is a project to call the three routines and display their results side by side. In case your wondering about Datediff it returns the number of times the year, month or whatever has changed between the two date. i.e. it returns 1 when from is dec 31 yyyy and to is jan 1 yyyy+1. Anyway here are three routines, two of them worked in all the test conditions I tried, the other gets a wild hair up it rear every once in a while. Louis Boldt 2/16/02
I hope that this is the shortest and easiest wordwrap-function in vb you have ever seen, that you enjoy it and use it in all your projects :-)
This teaches users how to manipulate strings using. Left(),Right(),Mid(),Len(),Instr(),Lcase(),Ucase() and StrReverse().
I looked on this site to find something like this, but i didnt find exactly what i wanted. Here is the source that i created that takes random characters from a text box and places them in a label. It takes a user defined amount of characters including spaces and periods and everything else. =) UPDATED AGAIN!! Now has added features! Can count characters and vowels and words etc! If you know a better way to do this, please email me. This type of program can be used for fortunes, making up new words, choosing usernames(i actually know somebody that did this with a similar program), etc. PLEASE VOTE!!!