Results for "Category: String Manipulation"
With this application you can test the connection to a SQL server prior to adjusting your connectionstring of your application. It can attemp to connect by socket and by connecting to the database. Instead of the IP adress a hostname can be used. If connection is possible then the connectionstring is copied to the clipboard Upgraded the code and made some new functionality Thanks for the feedback
' This easy code is design to open a text file, read a line at a time ' and take a set number of characters from the right hand side of each line ' This is a look at the basics of string and file manipulation ' I will also post a a program that will find a character and ' get the data left or right of it.
This is a .bas module that contains a few string manipulation functions I find useful in the real word. MakeProper replaces the limited proper case functions of VB with code that will format your string in title case, but not force mid-word capital letters to lower case. So "John Smith III" or "MacDonald" comes out correctly if typed are typed as "john smith III" or "macDonald". Initial letters of words are capitalized, but other letters are left as typed. DateWord takes a date and converts it to the phrasing used on legal documents, so 1/1/2000 would return "1st day of January, 2000." MailingLabelText accepts a number of inputs and returns a UDT that offers many variations on the name and address for use in creating mailing labels and other reports containing name and address data. The proper business ettiquette is observed in that the presence of an honorific like "Esquire or MD" eliminates the "Mr." or "Dr." Look for an update of this soon with more functions for string manipulation. The other functions are used by these three. LogError is pretty useful, too, come to think of it! I don't care about winning any prizes, I just wanted to contribute to a site that has helped me out so much. Your feedback is welcome all the same. PLEASE STILL RATE THIS SO I WILL KNOW WHAT YOU THINK!
Tutorial to teach about LTrim, RTrim, Trim, Left, Right, Mid, StrReverse, creating your own stringreverse function, Replace, InStr, and simple text encryption. 2500 Word approx and examples included
This code should explain the bubble sort ! Bubble sort is a sort algorithm that sortes string in very fast way. There are many sort algorithms but this is the best !
4 functions to handle command line options...example: yourprogy.exe -F, etc...one of them checks if a commandline option is in the command line....another one creates a commandline set with options...another one removes a specified option from the command line, and return the cmdline...(example: sometext -F, to sometext)...and the last one pulls out the text between 2 options in the commandline, and returns it...so -S blah -E would return just "blah"..can be very usefull...
Swap Variable1 for Variable2 using API, this is usefull for creating data processing programs with many stored variables. See Info below
The code will take a passed string and a delimiter and parse the string into a variant array for reading. Works very well with csv files, etc.
(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!