Get unix micro time in VB.NET

Public Shared Function GetUnixMicroTime() As String Dim origin As DateTime = New DateTime(1970, 1, 1, 0, 0, 0, 0) Dim diff As TimeSpan = Now() – origin Return CStr(diff.TotalSeconds) End Function

Uppercase first in VB.Net

To capitalize only the first character of a string you can create an extension, like this: Public Module MyModule Public Function UppercaseFirst(my_string As String) As String If String.IsNullOrWhiteSpace(my_string ) OrElse my_string .Length < 2 Then...

Rtrim and Ltrim specific chars in VB.Net

Dim char_array_end = "<br />".ToCharArray Dim char_array_start = "I ".ToCharArray Dim my_string = "I love pizza, beer, sambuca<br />" Dim my_string_trimmed = my_string.TrimEnd(char_array_end) Console.WriteLine(my_string_trimmed) ‘I love pizza, beer, sambuca’ my_string_trimmed = my_string.TrimStart(char_array_start) Console.WriteLine(my_string_trimmed) ‘love pizza,…

VB.NET – Trim all rows in a string

Dim my_string As String = vbTab & “row1 ” & vbNewLine & “” & vbTab & ” row2 ” Dim rows As String() = my_string.Split(vbNewLine) Dim text As StringBuilder = New StringBuilder For Each row…

VB.Net convert string to title case

Our advice is to create an extension, so you can directly use the new function on strings: Public Module MyExtensions <System.Runtime.CompilerServices.Extension()> Public Function ToTitleCase(mystring As String) As String Return System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(mystring) End Function End Module Now…