Home

VB.NET: List Classes That Inherit Interface

Posted by SteveHardie | On: May 19 2011 | Comments (0)
I want to be able to create a list of all classes that inherit a specified interface within a given namespace. Here is a quick bit of code that will give you a list of System.Type wich will contain all classes that inherit the specified interface.

tSQL Return Identity When Adding New Record

Posted by SteveHardie | On: Mar 21 2011 | Comments (0)
@@Identity (Transact-SQL) Is a system function that returns the last-inserted identity value. To use this in a tSQL statement, you need to declare an output variable and set the value after inserting a new row into a table. SET @RecordID=@@IDENTITY Using...

Read Text From/Write Text To a File

Posted by SteveHardie | On: Nov 13 2009 | Comments (0)
This is a quick and easy way to read a files content into a string, or write a string to a file. Read File Contents: Dim strContent As String Using fs As New IO.StreamReader(fileName) strContent = fs.ReadToEnd End Using Write content to file: Dim strContent...

VB.NET Format File Size

Posted by SteveHardie | On: Oct 07 2009 | Comments (1)
Format a large integer (long) that represents a file size in bytes to a more readable string representation that includes Kb, Mb and Gb. Public Shared Function FormatFileSize(ByVal FileSizeBytes As Long) As String Dim sizeTypes() As String = {"b",...

VB.NET Finding a File Size

Posted by SteveHardie | On: Oct 07 2009 | Comments (0)
There may be some situations where you would like to retrieve the size of a given file. Below is a quick piece of code that will do exactly that. It will return the size of the file in bytes. Imports System.IO Private Function GetFileSize(ByVal MyFilePath As String)...

Regular Expression Validation for Email Address

Posted by SteveHardie | On: Sep 29 2009 | Comments (0)
In almost all cases, it is a good practice to validate the users input because of many reasons (i.e. security, reliability, as proof of the given template, etc.). There is a quick and simple way to check if a text box entry contains a valid email address. A valid...