'-----------------------------------
'MULTI-DIMENSIONAL ARRAY
'-----------------------------------
'*** Create Array and append values to it
Dim itemsArray As String()() = New String(0)() {}
For i = 1 To 3
ReDim Preserve itemsArray(i)
itemsArray(i) = New String() {"1", "2", "3"}
Next
'Output:
' 1 2 3
' 1 2 3
' 1 2 3
'*** Free array's memory
Array.Clear(itemsArray, 0, itemsArray.Length)
Erase itemsArray
'-----------------------------------
'NUMBER FORMATTING
'-----------------------------------
Dim FormattedNumber As String = String.Format("{0:N0}", 123456)
'Output: 123,456
'*** Decimals:
'use 'F' fixed point format with '3' decimal places.
Dim PrintableNumber As String = String.Format("{0:F3}", 0.126467382626182)
'Output: 0.126
'*** Padding:
'The 'D' means padded decimal integer and the '4' means to 4 places,
'so you end up with a 4 digit printable number that's prefixed with 0's where needed.
Dim Result As Integer = 20
Dim PrintableNumber As String = String.Format("{0:D4}", Result)
'Output: 0020
'-----------------------------------
'DATE & TIME FORMATTING
'-----------------------------------
Dim MyDate As String = String.Format("{0}", DateTime.Now)
'Output: 14/04/2014 13:47:32
'Which will be formatted according to your local culture settings.
'Just as with the number formatting strings, there is a wide range of possible operators
'you can use here to get just the format you need; for example:
Dim MyDate As String = String.Format("{0:r}", DateTime.Now)
'Output: Mon, 14 Apr 2014 13:52:41 GMT
'Where as:
Dim MyDate As String = String.Format("{0:s}", DateTime.Now)
'Output: 2014-04-14T13:53:37
'Custom formatting:
Dim MyDate As String = String.Format("{0:yyyy - dd MMMM @ hh:mm tt}", DateTime.Now)
'Output: 2014 - 14 April @ 01:57 PM