Results 1 to 6 of 6

Thread: a loop in my program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    187

    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!!!

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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:
    1. If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK
    2.    For Each str As String In OpenFileDialog1.FileNames
    3.              MessageBox.Show(str)
    4.    Next
    5. End If
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    187

    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.

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    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?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    187

    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.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    187

    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
  •  



Click Here to Expand Forum to Full Width