devxlogo

Tip Bank

Transform a variable into a Property

Thanks to Visual Studio.NET macros, it is quite simple to automate the task of transforming a Public field into a Property with the same name that accesses a private field

Quickly swap assignment operands

It often happens that you need to swap the operands of an assignment. For example, say that you have this set of assignments: p1.FirstName = m_FirstNamep1.LastName = m_LastName and later

Write a console utility to list processes

The Process class provides all you need to create a command-line utility that lists all the processes running on the system and all the related information. This utility is therefore

Wait for a process to terminate

You can use the VB.NET Shell command (in the Microsoft.VisualBasic namespace) to run an external process and wait for its termination, but you can get better control if you work

FormatMemorySize – Format a value in bytes

Enum FormatMemorySizeUnits BestGuess Bytes Kilobytes Megabytes GigabytesEnd Enum’ convert a number of bytes into Kbytes, Megabytes, or GigabytesFunction FormatMemorySize(ByVal value As Long, _ ByVal unit As FormatMemorySizeUnits, Optional ByVal decimalDigits