IsNothing versus Is Nothing

If you take a look at the MSIL as it’s being executed you’ll see that it doesn’t compile down to the exact same code. When you use IsNothing() it actually makes a call to that method as opposed to just evaluating the expression. The reason I would tend to lean towards using “Is Nothing” is … Read more

How to order list of files by file name with number?

It sounds like you might be looking for a “NaturalSort” – the kind of display File Explorer uses to order filenames containing numerals. For this you need a custom comparer: Imports System.Runtime.InteropServices Partial Class NativeMethods <DllImport(“shlwapi.dll”, CharSet:=CharSet.Unicode)> Private Shared Function StrCmpLogicalW(s1 As String, s2 As String) As Int32 End Function Friend Shared Function NaturalStringCompare(str1 As … Read more

Passing parameter to query for Access database

I would first create an OleDbCommand object and use this object to create a OleDbDataAdapter Imports Data.OleDb dim cmd as new OleDbCommand cmd.Connection = con cmd.CommandType = CommandType.Text cmd.CommandText = “SELECT * FROM tblContacts where Name=? and City=?” ‘ Here we add the parameters in the same order they appear in the ‘ CommandText. The … Read more

.DrawImage with opacity?

You have to use a ColorMatrix to blend images. Here’s a C# control I wrote a while ago, it shows you the basic code you’ll need. Not VB.NET code but, hey, you didn’t try real hard either: using System; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; public class BlendPanel : Panel { public BlendPanel() { DoubleBuffered … Read more

How to print hidden and visible content of a Container with ScrollBars

These sets of methods allow to print the content of a ScrollableControl to a Bitmap. A description of the procedure: The control is first scrolled back to the origin ([ScrollableControl].AutoScrollPosition = new Point(0, 0) (an exception is raised otherwise: the Bitmap has a wrong size. You may want to store the current scroll position and … Read more

Doing math in vb.net like Eval in javascript

There’s a shortcut for limited (ie. simple) math expressions by using the DataTable.Compute method. Obviously, this isn’t robust (limited functionality) and feels hackish to misuse the DataTable for this purpose, but I figured I would add to the current answers. Example: var result = new DataTable().Compute(“3+(7/3.5)”, null); // 5 “Sin(90)” wouldn’t work with this approach. … Read more

Clickable URL in a Winform Message Box?

One option is display the url in the message box, along with a message and provide the help button that takes you to that url: MessageBox.Show( “test message”, “caption”, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0, ‘0 is default otherwise use MessageBoxOptions Enum “http://google.com”, “keyword”) Important to note this code cannot be in the load event of the … Read more

How to listen keyboard in background and fire keystrokes on demand?

Source : Here Usage: To create the hook Private WithEvents kbHook As New KeyboardHook Then each event can be handled: Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyDown Debug.WriteLine(Key.ToString) End Sub Private Sub kbHook_KeyUp(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyUp Debug.WriteLine(Key) End Sub Keyboard Hook Class : Imports System.Runtime.InteropServices Public Class KeyboardHook <DllImport(“User32.dll”, CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _ … Read more