Guide Contents
|
DigitalDan Home Page
|
Private Shared Function WordCount(text As String) As Integer
Dim wordColl As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(text, "[\S]+")
Return wordColl.Count
End Function
Private Shared Function Lleft(text As String, length As Integer) As String
' alternative to Microsoft.VisualBasic.Left(text,length)
If length < 1 Then Return ""
If length >= Len(text) Then Return text
Return Mid(text, 1, length)
End Function
'
Private Shared Function Rright(text As String, length As Integer) As String
' alternative to Microsoft.VisualBasic.Right(text,length)
If length < 1 Then Return ""
If length >= Len(text) Then Return text
Return Mid(text, Len(text) - length + 1, length)
End Function
Private Shared Function RemoveCharacters(text As String, start As Integer, numberOfCharacters As Integer) As String
Return text.Remove(start, numberOfCharacters)
End Function
Private Shared Function InsertCharacters(originalText As String, insertAt As Integer, toBeInserted As String) As String
Return originalText.Insert(insertAt, toBeInserted)
End Function
Private Shared Function RemoveCharacters(text As String, start As Integer, numberOfCharacters As Integer) As String
Return text.Remove(start, numberOfCharacters)
End Function
Dim text as String = number.ToString("___")
# | If Digit Is part Or number Then use the digit, otherwis pad the number With a leading/trailing space |
0 | If Digit Is part of number then use the digit, otherwise pad number with a leading/trailing zero |
; | Anything before ; applies to +ve numbers, all after ; applies to negative numbers |
. | Decimal Point to be shown at this position |
,. | Divide number by 1000 (,,. = /1000000 etc.) |
, | (Not next to .) - show a "thousand separator" in this position |
C | Use a currency symbol{-£1,234.57} |
E+ | Use Exponential notation e.g. "00E+00" {-12E+02} |
E- | The same as E+ but omit the + sign if exponential Is positive |
F | Number of digits after decimal point e.g. "F2" {-1234.57} |
G | Shortest of F Or E+ e.g. "G2" {-1.2E+03} |
N | Set number of decimal places & add thousand separators e.g. "N2" {-1,234.57} |
P | Convert to percent with thousand separators e.g. "P2" {-123,456.79%} |
R | Used to avoid rounding errors in certain circumstances {-1234.56789} |
\ | Escape charater (Insert next charater into the string, even if it normally has a special meaning) |
D | Force a minimum number of digits (pad with 0) e.g 1234 "D7" {0001234} This Is minimum digits, number will Not truncate e.g. -1234 "D2" {-1234} |
X | Convert to Hex using 0-9 And A-F e.g. 1234 {4D2} Negative numbers give a 2's compliment e.g. -1234 {FFFFFb2e} |
d | Identical to "D" |
x | Convert to Hex using 0-9 And a-f e.g. 1234 {4d2} Negative numbers give a 2's compliment e.g. -1234 {fffffb2e} |
Dim num As Double = 12.34
Dim txt as string
txt = num.ToString() ' text set to "12.34"
txt = num.ToString("000.000") ' txt set to "012.340"
txt = num.ToSTring("###000.0##") ' txt set to "012.34"
txt = num.Tostring("##0 . 0##") ' txt set to "12 . 34"
Private Function Merge_StringArray(separator As String, array() As String) As String
Return String.Join(separator, array)
End Function
Private Function Merge_List_Of_String(separator As String, listString As List(Of String)) As String
Return String.Join(separator, listString)
End Function
Private Function Split_String(separator As String, text As String, splitOptions As StringSplitOptions) As String()
Return text.Split(separator, splitOptions)
End Function
Private Function Split_String(separator As String, text As String, splitOptions As StringSplitOptions) As List(Of String)
Return text.Split(separator, splitOptions).ToList
End Function
Private Function Split_String(separator As String, text As String, maxParts As Integer, comparetype As CompareMethod) As String()
Return Split(text, separator, maxParts, comparetype)
End Function
Private Function Split_String(separator As String, text As String, maxParts As Integer, comparetype As CompareMethod) As List(Of String)
Return Split(text, separator, maxParts, comparetype).ToList
End Function