In earlier versions of Visual Basic, you use LoadPicture to load an image from a file. LoadPicture is missing from VB .NET so you need some other method.
This program starts by calculating the name of the file to open. It assumes it is running from the bin directory inside the main project directory that holds the target image file. It uses LastIndexOf to find "\bin" in the executable's directory, uses Substring to remove the end of the path, and adds on the file's name.
Next the program creates a new Bitmap object, passing its constructor the file's name. That loads the file into the Bitmap object. The program sets a PictureBox's Image property to the Bitmap to display the result. It also sets the control's SizeMode property to AutoSize so the whole image is visible.
|