VB.NET

PlayAVIPictureBox – Playing an AVI file in a PictureBox synchronously

Shared Function _ GetShortPathName(ByVal lpszLongPath As String, _ ByVal lpszShortPath As System.Text.StringBuilder, _ ByVal cchBuffer As Integer) As IntegerEnd Function’ Play an AVI file in a PictureBox synchronously.” fileName is a string containing the full path of the file.’ window is the PictureBox in which you want that the movie’

Adding styles to the font of the selected text of a RichTextBox

‘ Add a style to the selection of a RichTextBox,’ without deleting the current styles that may be already’ present in the selection or in portions of it” Example: AddFontStyle(richTextBox1, FontStyle.Bold)Public Sub AddFontStyle(ByVal rtb As RichTextBox, _ ByVal style As System.Drawing.FontStyle) ‘ if the selection length is > 0, work

Locale-aware string conversions

You can use the usual UCase, LCase, and StrConv functions to convert a string to upper, lower, and titlecase (e.g. “This Is A Title”). However, VB.NET offers is much more flexible, and lets you convert the case of a string according the locale you specify. You can do this through

StripControlChars – Delete control characters in a string

‘ Strip all control characters (ASCII code < 32)'' If the second argument is True or omitted,' CR-LF pairs are preservedFunction StripControlChars(source As String, Optional KeepCRLF As Boolean = _ True) As String Dim index As Long Dim bytes() As Byte ' the fastest way to process this string '

HasDuplicateValues – Check if an array has duplicate values

‘ Returns True if an array contains duplicate values’ it works with arrays of any typeFunction HasDuplicateValues(arr As Variant) As Boolean Dim col As Collection, index As Long Set col = New Collection ‘ assume that the array contains duplicates HasDuplicateValues = True On Error GoTo FoundDuplicates For index =

FilterDuplicates – Delete duplicate items in an array

‘ Filter out duplicate values in an array and compact’ the array by moving items to “fill the gaps”.’ Returns the number of duplicate values” it works with arrays of any type, except objects” The array is not REDIMed, but you can do it easily using’ the following code:’ a()