OMG so simple yet so hard picturebox help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
9 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Okay I want to save an image from a webpage in a way like IE or chrome ect I have tried this code yet it does not work and I have no IDEA why
Code: Select all
        Try
            Dim pbx As New PictureBox
            pbx.ImageLocation = ToolStrip1.Text
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save your Image as...."
            sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
            sfd.Filter = "Jpeg files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp"
            Dim result As DialogResult = sfd.ShowDialog
            If result = Windows.Forms.DialogResult.OK Then
                If sfd.FileName <> String.Empty Then
                    Dim MyImageFormat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    If sfd.FileName.ToString.ToUpper.EndsWith("JPG") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    ElseIf sfd.FileName.ToString.ToUpper.EndsWith("BMP") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Bmp
                    End If
                    pbx.Image.Save(sfd.FileName, MyImageFormat)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
Any help would be most aprechated
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

If it is from internet then why not use my.computer.network.downloadfile(toolstrip.text, sfd.filename) ?
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Mizzar I love you haha I had not thought of that needed a little tweaking but the compleat code is this if anyone else should need it
Code: Select all
  Try
            Dim label As New Label
            label.Text = ToolStripStatusLabel1.Text
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save your Image as...."
            sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
            sfd.Filter = "Jpeg files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp"
            Dim result As DialogResult = sfd.ShowDialog
            If result = Windows.Forms.DialogResult.OK Then
                If sfd.FileName <> String.Empty Then
                    Dim MyImageFormat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    If sfd.FileName.ToString.ToUpper.EndsWith("JPG") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
                    ElseIf sfd.FileName.ToString.ToUpper.EndsWith("BMP") Then
                        MyImageFormat = System.Drawing.Imaging.ImageFormat.Bmp
                    End If
                    My.Computer.Network.DownloadFile(label.Text, sfd.FileName)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

okay ones again needing help but does anyone know how to refresh the controls in a toolstrip I know
toolstrip.refresh
but that is not working the way I want I want to it remove all items and then put them all back again just I am loading items from a listbox
into a toolstrip that has to preset buttons and when I add a new one it is realoading the listbox items twise soo how can I fix this please
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

ToolStrip.Items.Clear() ?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Well i would use this but it will clear the 2 Buttons that i need to keep that are like allways there :P ?......
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Code: Select all
for each tsi as toolstripitem in toostrip.items
if typeof tsi is toolstripbutton and tsi.text ="YOURBUTTONTOSTAY" then
else
toolstrip.items.remove(tsi)
end if
next
Edit, this will remove every item in toolstrip except the one with text YOURBUTTON....
User avatar
DeveloperJacob
VIP - Donator
VIP - Donator
Posts: 87
Joined: Sun May 27, 2012 12:40 pm

Image
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

DeveloperJacomb I would use yours and it is amazing but tbh that would then just be copying and pasting most of what I need soo not doing it my self I mutch prefer giving it ago my self then asking you lot for help if I cant get it atleast that way it is my own or rather ours then just some random of the internet that I have changed the graphics of
9 posts Page 1 of 1
Return to “Coding Help & Support”