Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PictureBoxes and Buttons

Posted on 2004-11-11
3
Medium Priority
?
197 Views
Last Modified: 2010-04-24
Hey,

I'm new to the whole Visual Basic .NET. I have been using VB6 for awhile. I was wondering, how do you make it so in your form you click a command button and it loads an image from the harddrive into the picture box (e.g. "C:\test.jpg"). Code would help, thanks.
0
Comment
Question by:Linky
3 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 260 total points
ID: 12555007
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        picturebox1.image = image.fromfile("c:\test.jpg")
    End Sub
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 240 total points
ID: 12555056
Hi,

Here is where I found good examples for getting started in VB.Net

.....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx

Link for ASP programs...

http://msdn.microsoft.com/asp.net/downloads/kits/default.aspx 


sample code a find and open a file

  Public Sub OpenImages()
        Dim i As Short
        Dim myOpenFileDialog As New OpenFileDialog
        With myOpenFileDialog
            .CheckFileExists = True
            .DefaultExt = "bmp"
            .Filter = "Icon files(*.ico)|*.ico"
            .Filter += "|Bmp files (*.bmp)|*.bmp"
            .Filter += "|Jpeg files(*.jpg;*.jpeg;*.jpe;*.jfif)|*.jpg"
            .Filter += "|Gif files(*.gif)|*.gif"
            .Filter += "|Tif files(*.tif;*.tiff)|*.tif"
            .Filter += "|Png files(*.Png)|*.Png"
            .InitialDirectory = "c:\"
            .Multiselect = False
        End With
        ' Use the OpenFileDialog and put the path and name of the selected file in a var.
        If myOpenFileDialog.ShowDialog = DialogResult.OK Then
            sFileName = myOpenFileDialog.FileName
            sIconPath = Path.GetDirectoryName(sFileName) & "\"
            i = sFileName.LastIndexOf("\") + 1
            sFileName = sFileName.Substring(i)
        End If
    End Sub
0
 
LVL 2

Author Comment

by:Linky
ID: 12561652
Thank you both, I need to play with .NET looks interesting and fun.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 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