Word Wrap
Tuesday, 27 September 2011 20:58
Function WWrap(StrDummy As String, StrSize As Integer) As String
If Len(Trim(StrDummy)) < StrSize Then WWrap = StrDummy Exit Function End If
Dim StrLine1 As String Dim LoopI As Integer Dim IntJ As Integer LoopI = 1 StrLine1 = Mid(StrDummy, LoopI, StrSize) WWrap = "" While Trim(StrLine1) <> "" If (Mid(StrDummy, (LoopI - 1) * Len(StrLine1) + 1, 1) <> " ") Then IntJ = InStrRev(StrLine1, " ") If IntJ <> 0 Then StrDummy = Mid(StrDummy, 1, (LoopI - 1) * StrSize + IntJ - 1) + String(StrSize - IntJ + 1, " ") + Mid(StrDummy, (LoopI - 1) * StrSize + IntJ + 1) End If End If LoopI = LoopI + 1 StrLine1 = Padr(Mid(StrDummy, (LoopI - 1) * StrSize + 1, StrSize), StrSize) Wend WWrap = StrDummy End Function
Posting Articles
Friday, 23 September 2011 22:16
Greetings,
I will start tweaking and posting more articles very soon. I would like to encourage anyone who would like share some knowledge to register and post their own articles.
Have a wonderful day!
Emerson
Last Updated on Friday, 23 September 2011 22:52
|
InStr
Tuesday, 27 September 2011 14:43
InStr returns the first occurrence of a string inside another string.
InStr([start,] string1, string2 [, compare])
- start
- Optional. Character position where the search starts. If omitted, the search starts at the start of string1, position 1. Valid input values: 1 to Len(string1)
- string1
- The string to search in. Can be
Null . - string2
- The string to find. This is the text you want to find inside string1. It is usually shorter than string1. Can be
Null . - compare
- Optional. Specifies the type of string comparison.
vbBinaryCompare (0) performs a fast binary comparison where each character matches only itself. This is the default.
vbTextCompare (1) performs a text comparison.
vbDatabaseCompare (2). For Microsoft Access (Windows only), performs a comparison based on information contained in your database.
- If you omit compare, InStr will use the setting of the
Option Compare statement.
- Binary comparison is the safest option. Text comparison rules vary by the system locale. In text comparison, what matches on one computer may not match on another.
Return value
InStr returns one of the following values:
Null if either string1 or string2 is Null .
- start if string2 is empty.
- Character position of the first occurrence of string2 in string1.
- Zero if string2 was not found in string1.
Special cases:
- InStr(string1, "") returns 1 if string1 is not empty.
- InStr("", "") returns 0.
- If start exceeds the length of string1, there is never a match and InStr returns 0.
|