Visual Basic Code Snippets
Collection of Visual Basic (VB) code snippets
Recent articles in VB Code Snippets
- Populate ComboBox using DataTable. (VB) Visual Basic code snippet CreateDropDownMenu to populate ComboBox dropdown menu with given DataTable.
- Visual Basic Code Snippet - AddSlashes StripSlashes Escape String. (VB) Visual Basic code snippet AddSlahes tool allows quote a string with slashes (Escape String). Stripslashes snippet un-quotes a quote string by removing slashes.
- Visual Basic Code Snippet - Access current environment directories and logical drives. (VB) Visual Basic code snippets to access current environment directories such as current directory, system directory and logical drives.
- Visual Basic Code Snippet - Convert Unix timestamp. (VB) Visual Basic code snippets convert date/time between DateTime and Unix timestamp. Most .Net base applications never use Unix timestamp, but if you want to create a application to interact with other application or sites, maybe built in PHP or Java, use these methods to convert Unix timestamp.
- Visual Basic Code Snippet - Upload file to FTP Server. (VB) Visual Basic code snippet upload file to FTP Server. This method login to FTP server using username and password and upload the local file to given FTP location.
- Visual Basic Code Snippet - Validate (int) Integer. (VB) Visual Basic code snippets return the validated int value by checking validity of the given int and checking the int value range within the given minimum and maximum int range.
- Visual Basic Code Snippet - Find starting and ending date for given date. (VB) Visual Basic code snippets return the Ending Date and Starting Date for given date. Simply pass DateTime value that need to find date and snippets will return starting and ending date as DateTime.
- Visual Basic Code Snippet - Get local computer host name. (VB) Visual Basic code snippet get the host name from the local machine.
- Visual Basic Code Snippet - Get local computer IP address. (VB) Visual Basic code snippet get the IP address from the local machine. For computers with multiple IP addresses with one or more NIC cards can use IP address object list to obtain all the IP addresses.
- Visual Basic Code Snippet - Compile C# or VB source code run-time. (VB) Visual Basic code snippet compile C# or VB source code run-time from a text string or external text file and build the executable. Programmatically compile code using C#/VB compiler.
- Visual Basic Code Snippet - Save object to file. (VB) Visual Basic code snippet save object to external file. This function can be use to serialize objects into byte array and save them in external file.
- Visual Basic Code Snippet - Load object from binary file. (VB) Visual Basic code snippet open an external binary data file and convert it to object. This function can be use to deserialize those byte array data (Serialized) from external file to their original objects.
- Visual Basic Code Snippet - Byte array to object. (VB) Visual Basic code snippet convert byte array to object. This function useful to convert back byte array data to its original object representation. This function can be use to deserialize those byte array data (Serialized) to their original objects.
- Visual Basic Code Snippet - Object to byte array. (VB) Visual Basic code snippet convert object to byte array. This method useful to store binary data in files. This function can be use to convert any object to byte array and store them in database.
- Visual Basic Code Snippet - Save byte array to file. (VB) Visual Basic code snippet save byte array in to an external file. This function useful to store binary data in files. This function can be use when retrieving binary data from database and save it to an external file.
- Visual Basic Code Snippet - Convert file to byte array. (VB) Visual Basic code snippet convert external file to byte array. Converting file into byte array important to store binary file in database, send to other systems using remoting.
- Visual Basic Code Snippet - Execute Shell Commands from .Net. (VB) Visual Basic code snippet creates a command process and then invokes the command that we want to execute. The result of the command and any errors occurred during execution is stored in a string variables. This is a great method to execute your DOS commands from .Net.
- Visual Basic Code Snippet - Download HTML Web Page. (VB) Visual Basic code snippet download web page HTML source contents.
- Visual Basic Code Snippet - Download Image from URL. (VB) Visual Basic code snippet download image from URL. This function download image using web response stream.
- Visual Basic Code Snippet - Download File from URL. (VB) Visual Basic code snippet download file from URL and save it on local drive. These code snippets discuss both asynchronous file download method and DownloadFile method (to block thread while waiting for the download).
- Visual Basic Code Snippet - Send Email Using SMTP Server. (VB) Visual Basic code snippet connects to SMTP Email Server and send email message. SendEmail send email using SMTP email server.
Recent articles in VB Code Snippets
- Visual Basic Code Snippet - Get DataTable using open connection. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and return DataTable. GetDataTable returns DataTable using open database connection and SQL statement.
- Visual Basic Code Snippet - Get XmlReader using open connection. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and return XmlReader. ExecuteXmlReader returns XmlReader using open database connection and SQL statement.
- Visual Basic Code Snippet - Get Scalar using open connection. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and returns the first column of the first row in the result set returned by the query as a object. ExecuteScalar returns an object using open database connection and SQL statement.
- Visual Basic Code Snippet - Get Image from sql server. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and returns the Image data. ScalarToImage returns an Image using open database connection and SQL statement.
- Visual Basic Code Snippet - Check Record Exists in SQL Server Database. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement to determine whether the given record exists in the database. RecordExists returns logical (True/False) using open database connection and SQL statement.
- Visual Basic Code Snippet - ExecuteNonQuery against the SQL Server Database. (VB) Visual Basic code snippet connects to SQL server and executes a SQL statement and returns the number of rows affected. ExecuteNonQuery returns number of rows affected using open database connection and SQL statement.
- Visual Basic Code Snippet - Get Identity Column Value from SQL Server. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and returns the identity value. ExeSQLReturnLong execute SQL statement using ExecuteScalar method and return identity value as a long. ExeSQLReturnObject execute SQL statement using ExecuteScalar method and return identity value as an object.
- Visual Basic Code Snippet - Insert/Update Image To SQL Server. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and update/insert binary image data in database table. InsertUpdateImage update/insert image into database using open database connection, insert/update SQL statement, binary image and image format.
- Visual Basic Code Snippet - Get Data From SqlDataReader using open connection. This .Net Visual Basic code snippet connects to SQL server and executes SQL statement and return SqlDataReader. GetSqlDataReader returns SqlDataReader using open database connection and SQL statement.
- Visual Basic Code Snippet - Get Data From SqlDataReader. (VB) Visual Basic code snippet connects to SQL server and executes SQL statement and return SqlDataReader. GetSqlDataReader returns SqlDataReader for given database connection string and SQL statement.
- Visual Basic Code Snippet - Get First Row As Object Array From SqlDataReader. (VB) Visual Basic code snippet execute a SQL statement using open database connection and return all the columns data in SqlDataReader for first row. GetSqlDataReaderFirstRow execute and close SqlDataReader and returns first data row as a dictionary object array.
- Visual Basic Code Snippet - Remove White Spaces. (VB) Visual Basic code snippet to remove all white spaces from a string. TrimWhiteSpace strip all white spaces from a given.
- Visual Basic Code Snippet - Remove HTML Tags. (VB) Visual Basic code snippet to remove all HTML TAGS from a string. StripHTML strip all HTML tags from a given string and return plain text.
- Visual Basic Code Snippet - Extract Numeric values. (VB) Visual Basic code snippet to extracts all the numeric values from a string. ExtractNumbers returns string array of numeric values successful matches by iteratively applying a regular expression pattern to the input string.
- Visual Basic Code Snippet - Extract Emails. (VB) Visual Basic code snippet to extracts all the Emails from a string. ExtractEmails returns string array of Emails successful matches by iteratively applying a regular expression pattern to the input string.
- Visual Basic Code Snippet - Extract URLs. (VB) Visual Basic code snippet to extracts all the URLs from a string. ExtractURLs returns string array of URLs successful matches by iteratively applying a regular expression pattern to the input string.
- Visual Basic Code Snippet - Returns current UNIX timestamp. (VB) Visual Basic code snippet to return current UNIX timestamp. UnixTimeNow() returns current UNIX timestamp.
- Visual Basic Code Snippet - Validate Email Address. (VB) Visual Basic code snippet to validate given email address. IsValidEmail function validate email address. Function return TRUE if valid email address found, if not function will return FALSE.
- Visual Basic Code Snippet - Validate Integer. (VB) Visual Basic code snippet to validate given integer. IsInteger function validate integer. Function return TRUE if valid integer found, if not function will return FALSE.
- Visual Basic Code Snippet - Validate whole number. (VB) Visual Basic code snippet to validate given whole number. IsWholeNumber function validates positive integers with zero inclusive. Function return TRUE if valid whole number found, if not function will return FALSE.