Below you will find only four lines of code. But these four lines of code allow you to do something that would take hundreds of lines of code using a language such as C++. This source sample demonstrates how you can use Visual Basic's built in property called Screen to grab information about, wouldn't you know it, the screen that your application is running on. What this code does is queries the screen width and height. It then subtracts your forms width and height and divides it by two so you can put it in the middle.
To use this source code simply create a new VB project. Open the code for your form and add the following source to it.
You will notice that we are using the With construct that VB provides. All this does is causes Form1 to be implied before any . found in the code.
Note: The source for this was found at DreamVB which is no longer online.