|
-
Oct 28th, 2006, 03:30 AM
#1
Thread Starter
Addicted Member
a loop in my program
this is my code
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'apri file, open file
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
Label1.Text = "altezza immagine " & PictureBox1.Image.Height & " " & vbCrLf & "larghezza immagine" & PictureBox1.Image.Width & ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'salvataggio, 'save
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'ridimensionamento, resize
Dim i
i = TextBox1.Text
Dim ReBMP As New Bitmap(PictureBox1.Image, PictureBox1.Image.Width * i, PictureBox1.Image.Height * i)
PictureBox1.Image = ReBMP
Label1.Text = "altezza immagine " & PictureBox1.Image.Height & " " & vbCrLf & "larghezza immagine" & PictureBox1.Image.Width & ""
End Sub
now I want to repeat my program for every photo that I select in fileopendialog.
I've activated multiselect function, and i think to insert it a loop in my program , a for, but i don't understrand where I can insert it and how can i insert it...
can you help me????
thanks!!!
-
Oct 28th, 2006, 05:06 AM
#2
Re: a loop in my program
Please wrap your code in [VBCODE ] [/VBCODE ] tags to make it more readable.
Now about that loop. Heres how it works:
VB Code:
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK
For Each str As String In OpenFileDialog1.FileNames
MessageBox.Show(str)
Next
End If
-
Oct 29th, 2006, 02:05 AM
#3
Thread Starter
Addicted Member
Re: a loop in my program
ok I can to do it...and I do a button with this code
[VBCODE ]
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each filename As String In OpenFileDialog1.FileNames
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
Label1.Text = filename
Dim i
i = TextBox1.Text
Dim ReBMP As New Bitmap(PictureBox1.Image, PictureBox1.Image.Width * i, PictureBox1.Image.Height * i)
PictureBox1.Image = ReBMP
PictureBox1.Image.Save(Label1.Text)
Next
End If
End Sub
[/VBCODE ]
I want to overwrite files .png with the files that I load in picturebox and resize .
so I've associated filename = label1.text....(the path of load)...then I use to save them PictureBox1.Image.Save(Label1.Text)....but it's wrong...vb give me an error
why???
Last edited by stejano; Oct 29th, 2006 at 02:08 AM.
-
Oct 29th, 2006, 03:16 AM
#4
Re: a loop in my program
he meant the vbcode tag which is: [VBCODE ] without the space between the E and the ]
also what error is vb giving you?
-
Oct 29th, 2006, 03:24 AM
#5
Thread Starter
Addicted Member
Re: a loop in my program
generic error in GDI+
when debug arrive at picturebox1.image.save(label1.text)
Last edited by stejano; Oct 29th, 2006 at 03:31 AM.
-
Oct 29th, 2006, 04:16 AM
#6
Thread Starter
Addicted Member
Re: a loop in my program
I've find another error ....if I try with a savedialog....the program run but save always the same image....but I've selected more images.....why..heeelp!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|