Atlanta Custom Software Development 

   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
VB VB (1647)
VB.net VB.net (736)
C# C# (15)
ASP.net ASP.net (779)
ASP ASP (41)
VC++ VC++ (25)
PHP PHP (0)
JAVA JAVA (4)
JScript JScript (5)
  Database
» SQL Server (708)
» ORACLE (5)
» MySQL (0)
» DB2 (0)
Automation
» C/C++/ASM (11)
» Microcontroller (1)
» Circuit Design (0)
OS/Networking
» Networking (5)
» Unix/Linux (1)
» WinNT/2k/2003 (8)
Graphics
» Flash (0)
» Maya (0)
» 3D max (0)
» Photoshop (0)
Links
» ASP.net (2)
» PC Interfacing (1)
» Networking (4)
» SQL Server (4)
» VB (23)
» VB.net (4)
» VC (3)
» HTML/CSS/JavaScript (10)
Tools
» Regular Expr Tester
» Free Tools

(Page 1 of 3) 84 Result(s) found 

CamelCase - Convert a string to camel case
Total Hit (5164) «Code LangId=1» ' convert a string to camel case ' for example: CamelCase("new file name") => "NewFileName" ' Function CamelCase(ByVal Text As String) As String Dim i As Long ' convert all non-alphanumeric chars to spaces For i = Len(Text) To 1 Step -1 If InStr(1, ....Read More
Rating
Always use "$-typed" string functions
Total Hit (725) VB official documentation seems to encourage you to use "$-less" string functions, e.g. Left, LTrim or UCase, instead of their time-honored Left$, LTrim$ and UCase$ counterparts. If you do so, however, you should be aware that the former ones return a variant value that, when used within string expr ....Read More
Rating
Avoid append operations with the Replace function
Total Hit (672) I find the Replace function very useful when I want to avoid too many append operations just to insert non-printable characters. For example, the following statement: «Code LangId=1» MsgBox "Disk not ready." & vbCr & vbCr & _ "Please check that the diskette is in the drive" & vbCr & _ ....Read More
Rating
Count distinct characters in a string
Total Hit (1346) When you need to count how many occurrences of a given character are in a string, you might be tempted to go along the "traditional" Visual Basic way: «Code LangId=1» ' count spaces For i = 1 To Len(text) If Mid$(text, i, 1) = " " Then count = count + 1 Next «/Code» Ev ....Read More
Rating
Faster string appending with Mid$ command
Total Hit (818) As you probably know, the "&" operator is rather slow, especially with long strings. When you have to repeatedly append chucks of characters to the same variable, you can speed up your code using a simple trick based on the Mid$ command. The idea is that you pre-allocate a buffer long enough to acco ....Read More
Rating
Fixed-length strings allocate and deallocate faster
Total Hit (723) Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from conventional strings. However, arrays of fixed-length strings occupy a ....Read More
Rating
Fixed-length strings allocate and deallocate faster
Total Hit (726) Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from conventional strings. However, arrays of fixed-length strings occupy a ....Read More
Rating
Non obvious uses for the LIKE operator
Total Hit (702) LIKE is probably the VB operator is most underutilized if compared to its potential. The most immediate use for this operator is to check that a string begins or ends with a given pattern. For example, it is simple to check that a Product ID is made up by a alphabetic character followed by three dig ....Read More
Rating
Process string characters using Byte arrays
Total Hit (705) When you need to process each character in a string, you can assign the string to a byte array and iterate on its elements (remember: each Unicode character corresponds to two bytes). This approach is usually much faster because it saves a lot of Mid$ functions and, hence, a lot of temporary strings ....Read More
Rating
Replace the last occurrence of a string
Total Hit (721) Here is a one-liner that replaces the last occurrence of a substring in a string. It is slightly less efficient than using the InstrRev plus a Replace statement, but at least you can use it in-line inside another expression. And it is also one of the few occasions to use the StrReverse function, und ....Read More
Rating
Replicate a string of any length
Total Hit (698) The String$ function can replicate only 1-char strings, so it seems that you need a loop to duplicate strings that contain 2 or more characters. However, this is a one-liner that does the trick: «Code LangId=1» Function ReplicateString(Source As String, Times As Long) As String ' build a s ....Read More
Rating
Retrieve the currency symbol
Total Hit (633) It is very simple to retrieve the correct currency symbol, using just plain VBA statements: «Code LangId=1» currSymbol = Trim$(Replace(FormatCurrency(0,0), "0", "")) «/Code» If you can also determine if the symbol precedes or follows the currency amount using this method: «Code LangId=1» If ....Read More
Rating
Swap strings the fast way
Total Hit (984) Consider the usual way of swapping two strings: «Code LangId=1» Dim s1 As String, s2 As String Dim tmp As String ' initialize the strings s1 = String$(1000, "-") s2 = String$(1500, "+") ' do the swap, through a temporary variable tmp = s1 s1 = s2 s2 = tmp «/Code» If you put the abo ....Read More
Rating
Tricks with LCase and UCase
Total Hit (633) There are a few tricks that you can do with LCase$ and UCase$ functions. I doubt you will be using this tip in all your applications, but here they are for when you'll need them. Say you wish to check that a string (or a portion of it) does NOT include any alphabetical characters: instead of set ....Read More
Rating
Two handy functions for Null handling
Total Hit (825) You're probably aware that most VB functions don't work well with Null values, which is an issue when you're working with database columns that can accept Nulls. For example, the following statement: «Code LangId=1» Dim s as String s = rs.Fields("AnyField") «/Code» can raise error 94 "Invali ....Read More
Rating
IsValidEmail - Validate an email address
Total Hit (644) «Code LangId=1»' Validates an email address ' Returns True if valid, False if invalid ' ' Example: ' If IsValidEmail(Value:="x@y.com", MaxLength:=255, IsRequired:=True) then ... Function IsValidEmail(ByRef Value As String, Optional ByVal MaxLength As Long = _ 255, Optional ByVal IsRequi ....Read More
Rating
IsValidSSN - Check a Social Security Number value
Total Hit (748) «Code LangId=1»' Validates attributes of the SSN ' Returns True if valid, False if invalid ' 'Example: ' If IsValidSSN(Value:="333-44-3333", IsRequired:=True) then ... Function IsValidSSN(ByRef Value As String, Optional ByVal IsRequired As Boolean _ = True) As Boolean On Error ....Read More
Rating
CheckUSState - Validate a US state initial
Total Hit (569) «Code LangId=1»Public Function CheckUSState(ByVal State As String) As Boolean If Len(State) = 2 And InStr(",AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL,GA,HI,ID,IL,IN,I" _ & "A,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,P" _ & "A,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,", ....Read More
Rating
ConvertCamelCase - Convert from a string in camel case
Total Hit (750) «Code LangId=1»' change a sentence in CamelCase to a sentence with spaces ' for example ConvertCamelCase("FileExchange") => "File Exchange" Public Function ConvertCamelCase(ByVal Value As String) As String Dim i As Long For i = 1 To Len(Trim$(Value)) ' If the character is up ....Read More
Rating
ConvertReverseFullName - Convert a reverse name to the "FirstName LastName" format
Total Hit (606) «Code LangId=1» ' convert a reversed full name back to the "FirstName LastName" format ' ' for example, ConvertReverseFullName("Smith, John A.") ==> "John A. Smith" Function ConvertReverseFullName(ByVal ReverseFullName As String) As String Dim i As Long ReverseFullName = Trim$( ....Read More
Rating
EncryptString - Encode and decode a string
Total Hit (888) «Code LangId=1» Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _ Any, source As Any, ByVal bytes As Long) ' encrypt a string using a password ' ' you must reapply the same function (and same password) on ' the encrypted string to obtain the original, non-enc ....Read More
Rating
ExplodeString - Add a filling char between a string's chars
Total Hit (633) «Code LangId=1»' "Explode" a string by inserting a given filling character ' between consecutive characters in the original string ' ' The source string cannot contain Chr$(0) characters Function ExplodeString(Source As String, Optional fillChar As String = " ") As _ String ExplodeSt ....Read More
Rating
FilterString - Remove invalid characters from a string
Total Hit (768) «Code LangId=1»' Filter out all invalid characters in a string. Function FilterString(text As String, ValidChars As String) As String Dim i As Long, result As String For i = 1 To Len(text) If InStr(ValidChars, Mid$(text, i, 1)) Then result = result & Mid$(text, i, ....Read More
Rating
FormatCreditCard - Format a credit card number
Total Hit (958) «Code LangId=1»' Format a credit card number Function FormatCreditCard(ByVal text As String) As String Dim i As Long ' ignore empty strings If Len(text) = 0 Then Exit Function ' get rid of dashes, spaces and invalid chars For i = Len(text) To 1 Step -1 ....Read More
Rating
FormatFullName - Create a full name in the format "LastName, FirstName"
Total Hit (544) «Code LangId=1»' Takes a first and last name and converts it to the format LastName, FirstName Function FormatFullName(ByVal FirstName As String, ByVal LastName As String) As _ String FirstName = Trim$(FirstName) LastName = Trim$(LastName) If FirstName = "" Then ....Read More
Rating
FormatPhoneNumber - Format a phone number
Total Hit (717) «Code LangId=1»' Modify a phone-number to the format "XXX-XXXX" or "(XXX) XXX-XXXX". Function FormatPhoneNumber(ByVal text As String) As String Dim i As Long ' ignore empty strings If Len(text) = 0 Then Exit Function ' get rid of dashes and invalid chars For i ....Read More
Rating
GetDelimitedText - Extract the text between open and close delimiters
Total Hit (621) «Code LangId=1»' get the text enclosed between two Delimiters ' ' it advances Index after the close delimiter ' Returns "" and Index = 0 if not found ' search is case insensitive Function GetDelimitedText(Text As String, OpenDelimiter As String, _ CloseDelimiter As String, index As Long) ....Read More
Rating
GetStringBetweenTags - Returns a string between 2 delimiters
Total Hit (715) «Code LangId=1»' Returns a string between 2 delimiters ' Parameters: ' sSearchIn: String to search ' sFrom: First keyword ' sUntil: Second keywords ' nPosAfter: Gets the position after ' ' Example: ' Debug.Print GetStringBetweenTags("<html>This is a sample of title</html>", ' ....Read More
Rating
InStrAfter - An InStr variant that returns the index after the matching string
Total Hit (565) «Code LangId=1»' search for a string starting at a given index ' and return the index of the character that follows ' the searched string (case insensitive search) Function InstrAfter(Source As String, Search As String, _ ByVal index As Long) As Long InstrAfter = InStr(index, Source, ....Read More
Rating
InstrLast - Find the last occurrence of a substring
Total Hit (614) «Code LangId=1» ' returns the last occurrence of a substring ' The syntax is similar to InStr Function InstrLast(ByVal Start As Long, Source As String, search As String, _ Optional CompareMethod As VbCompareMethod = vbBinaryCompare) As Long Do ' search the next occurrence ....Read More
Rating


(Page 1 of 3) 84 Result(s) found  1 2 3

Recommanded Links

 

Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  Blogs

© 2008 BinaryWorld LLC. All rights reserved.