Loading a picture in STDPicture for VB.NET

Posted on 2005-04-18
Last Modified: 2008-03-06
Is there a way to load a bitmap into a STDPicture datatype in VB.NET?  I am concluding that Microsoft has disabled this feature, if so what did they replace it with?
Question by:Vasguard
    LVL 32

    Accepted Solution

    The Image class replaces the StdPicture object.

    Dim pic As Image
    pic = Image.FromFile("c:\16color.bmp")

    PictureBox1.Image = pic
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    If you only use Image.FromFile() to load an image, the image file will be locked until you release it by disposing of the Image() class instance.  You can, however, create a Bitmap() from the Image() instance and then dispose of the Image() instance to prevent the file lock:

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim fileName As String = "c:\someImage.jpg"
            Dim tempImg As Image = Image.FromFile(fileName)
            PictureBox1.Image = New Bitmap(tempImg)
        End Sub


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now