|
|
ConcatenateStrings - Concatenating an array of strings
|
Total Hit (2713) |
«Code LangId=2»' Concatenate the input strings, and return the resulting string. The first
' input string is used as a separator.
'
' Example:
' Dim i As Integer = 4
' Dim d As Double = 34.45
' Dim s As String = "VB-2-The-Max"
' Dim ret As String = ConcatenateStrings(" ", s, "is a n
....Read More |
Rating
|
|
|
CountOccurrences - Counting the number of string occurrences
|
Total Hit (2847) |
«Code LangId=2»
' Count the number of string occurrences
Public Function CountOccurrences(ByVal source As String, ByVal search As String, _
Optional ByVal ignoreCase As Boolean = False) As Integer
Dim options As System.Text.RegularExpressions.RegexOptions
' set the search options a
....Read More |
Rating
|
|
|
DecodeBase64 - Decoding a string from base64
|
Total Hit (2890) |
«Code LangId=2»' Returns the input string decoded from base64
Private Function DecodeBase64(ByVal input As String) As String
Dim strBytes() As Byte = System.Convert.FromBase64String(input)
Return System.Text.Encoding.UTF8.GetString(strBytes)
End Function
«/Code»
....Read More |
Rating
|
|
|
EncodeBase64 - Encoding a string to base64
|
Total Hit (3047) |
«Code LangId=2»' Returns the input string encoded to base64
Private Function EncodeBase64(ByVal input As String) As String
Dim strBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(input)
Return System.Convert.ToBase64String(strBytes)
End Function
«/Code»
....Read More |
Rating
|
|
|
|
ExplodeString - Add a filling char between a string's chars
|
Total Hit (2496) |
«Code LangId=2»
' "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(ByVal Source As String, Optional ByVal fillChar As Char = _
" "c) As String
....Read More |
Rating
|
|
|
|
FormatMemorySize - Format a value in bytes
|
Total Hit (2764) |
«Code LangId=2»
Enum FormatMemorySizeUnits
BestGuess
Bytes
Kilobytes
Megabytes
Gigabytes
End Enum
' convert a number of bytes into Kbytes, Megabytes, or Gigabytes
Function FormatMemorySize(ByVal value As Long, _
ByVal unit As FormatMemorySizeUnits, Optional B
....Read More |
Rating
|
|
|
FormatSize - Format a size expressed in bytes
|
Total Hit (2479) |
«Code LangId=2»
' Returns a formatted string that shows the size in Bytes, KBytes or MBytes
' according to the size
' Usage:
' Dim ProperSizeString As String = FormatSize("132100842")
' -> returns "125.98 MB"
Function FormatSize(ByVal SizeInBytes As Double) As String
If SizeInBytes
....Read More |
Rating
|
|
|
FormatValue - Format a value in a column of given width
|
Total Hit (2714) |
«Code LangId=2»
Enum FormatColumnAlignment
Left
Center
Right
End Enum
' format a value in a column of given width and with specified alignment
' using the specified pad character
Function FormatValue(ByVal value As String, ByVal width As Integer, _
ByVal alignment As F
....Read More |
Rating
|
|
|
|
|
|
|
InstrTbl - Search a string for any character in a table
|
Total Hit (3579) |
«Code LangId=2»
' If INCLUDE is True or is omitted, return the first occurrence of a character
' in a group
' or -1 if SOURCE doesn't contain any character among those listed in TABLE.
' If INCLUDE is False, return the first occurrence of the character in SOURCE
' that does not appear in TABL
....Read More |
Rating
|
|
|
InstrTblRev - The last occurrence of a char in a table
|
Total Hit (3361) |
«Code LangId=2»' If INCLUDE is True or is omitted, return the last occurrence of a character
' in a group
' or -1 if SOURCE doesn't contain any character among those listed in TABLE.
' If INCLUDE is False, return the last occurrence of the character in SOURCE
' that does not appear in TABLE.
....Read More |
Rating
|
|
|
|
|
|
|
|
ReverseString - Reversing a String
|
Total Hit (1624) |
«Code LangId=2»
' Reverse the input string, without using the StrRever function in the VB6
' compatibility assembly
Function ReverseString(ByVal source As String) As String
Dim chars() As Char = source.ToCharArray()
Array.Reverse(chars)
Return New String(chars)
End Function
«
....Read More |
Rating
|
|
|
SearchString - Searching a string in case [in]sensitive mode
|
Total Hit (2307) |
«Code LangId=2»
' Search the specified string, with the case-sensitive mode or not
' Returns the index of the first occurrence found, or -1 if not found
Public Function SearchString(ByVal source As String, ByVal search As String, _
Optional ByVal ignoreCase As Boolean = False) As Integer
....Read More |
Rating
|
|
|
Bin - Convert from decimal to binary
|
Total Hit (3746) |
«Code LangId=2»' convert from decimal to binary
' if you pass the Digits argument, the result is truncated to that number of
' digits
'
' you should always specify Digits if passing negative values
Function Bin(ByVal value As Long, Optional ByVal digits As Short = -1) As String
' conver
....Read More |
Rating
|
|
|
BinToDec - Convert from binary to decimal
|
Total Hit (3673) |
«Code LangId=2»' convert from binary to decimal
Function BinToDec(ByVal value As String) As Long
' we just need a call to the Convert.ToInt64 static method
Return Convert.ToInt64(value, 2)
End Function
«/Code»
|
Rating
|
|
|
Dec2Any - Convert a decimal number to any other base
|
Total Hit (3953) |
«Code LangId=2»' convert a positive number to any base
' BASE can be in the range 2-36
Function Dec2Any(ByVal number As Long, ByVal base As Short) As String
Dim index As Integer
Dim digitValue As Integer
Dim res As New System.Text.StringBuilder()
Const digits As String = "0
....Read More |
Rating
|
|
|
EvaluateModule - a module for evaluating expressions
|
Total Hit (2582) |
«Code LangId=2»' A module for evaluating expressions, with support for
' parenthesis and many math functions
' Example:
' Dim expr As String = "(SQR(9)^3)+COS(0)*3+ABS(-10)"
' txtResult.Text = Evaluate(expr).ToString ' ==> 27+3+10 ==> 40
Imports System.Text.RegularExpressions
M
....Read More |
Rating
|
|
|
Hex - Convert from decimal to hexadecimal
|
Total Hit (3873) |
«Code LangId=2»' convert from decimal to hexadecimal
' if you pass the Digits argument, the result is truncated to that number of
' digits
'
' you should always specify Digits if passing negative values
Function Hex(ByVal value As Long, Optional ByVal digits As Short = -1) As String
' c
....Read More |
Rating
|
|
|
Hex2Dec - Convert from hexadecimal to decimal
|
Total Hit (8208) |
«Code LangId=2»' convert from hexadecimal to decimal
Function HexToDec(ByVal value As String) As Long
' we just need a call to the Convert.ToInt64 static method
Return Convert.ToInt64(value, 16)
End Function
«/Code»
|
Rating
|
|