Wednesday, 15 April 2015

How to Display Picture in VB.NET Form


VB is an acronyms that stands for Visual Basic established by Microsoft Cooperation, it is a part of the .NET Framework (a bundle of programming platform where code re-useability and language interoperability  is encouraged)
Now, I will be showing you how to upload passport photograph in your windows application form, you might be wondering how to archive that maybe in your final year project of a project contracted to you. Follow the instruction bellow:
  1. In your application form, insert the following elements:
  • TextBox,     name this control "textbox1"
  • OpenFile Dialogue Box     leave this control at the default name "OpenFileDialogueBox1"
  • Two Buttons.     name one "browse" and the other "Upload" respectively.
  • A picture Box
 Set the ReadOnly property of the TextBox to TRUE so that user of the application will not be able to input text/characters in the textbox,

insert the following line of code in the click event of one of the buttons (double click the button then paste these codes:

        OpenFileDialog1.ShowDialog()
        With OpenFileDialog1
            .CheckFileExists = True
            .CheckPathExists = True
            .Title = "Select a file to open"
            .DereferenceLinks = True
            .Multiselect = False
            .DefaultExt = "jpg"

        End With
        TextBox1.Text = OpenFileDialog1.FileName
After inserting the above codes in the click event of the first button, then you will still need to copy the code bellow in the click event of the second button:
PictureBox1.ImageLocation = TextBox1.Text