Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Imports System.Text
- Public Function Lines(Optional ByVal line As UInteger = 0) As String
- 'Dim Store As New StringBuilder
- Dim Store As String = String.Empty
- For i As Integer = 0 To line
- 'Store.AppendLine()
- Store &= vbCrLf
- Next
- 'Return Store.ToString
- Return Store
- End Function
- Public Function ReadLn() As String
- Return Console.ReadLine
- End Function
- Public Function Read() As ConsoleKeyInfo
- Return Console.ReadKey
- End Function
- Public Sub PrintFancy(Optional ByVal Parts() As Object = Nothing)
- If Parts IsNot Nothing AndAlso Parts.Length > 1 AndAlso Parts.Length Mod 2 = 0 Then
- Dim Store As New StringBuilder
- Dim args((Parts.Length / 2) - 1)
- Dim Place As Integer = 0
- For i = 1 To Parts.Length - 1 Step 2
- args(Place) = Parts(i)
- Place += 1
- Next
- For i = 0 To Parts.Length - 1 Step 2
- Try
- Store.AppendLine(String.Format(Parts(i), args))
- Catch ex As Exception
- Continue For
- End Try
- Next
- Console.WriteLine(Store.ToString)
- Else
- Console.WriteLine()
- End If
- End Sub
- '' Returns a new array that contains every Nth element from a given array starting from index 0
- '' Offset is used to define which index to start with (less than the distance N)
- Public Function Nth(Of T)(ByVal Array() As T, ByVal N As UInteger, Optional ByVal Offset As UInteger = 0) As T()
- If N = 1 Then Return Array.Clone
- If Math.Abs(Offset) <= N - 1 Then
- Dim Store((Array.Length / N) - 1) As T, Place As Integer = 0
- For i As UInteger = Offset To Array.Length - 1 Step N
- Store(Place) = Array(i)
- Place += 1
- If Place >= Store.Length Then Return Store
- Next
- End If
- Throw New Exception("Offset must be less than the distance N")
- End Function
Advertisement
Add Comment
Please, Sign In to add comment