Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have an image viewer that i coded into my program and it has a listbox that lists all the image files in a certain directory, for example:

 

image001.bmp

image002.jpg

image003.png

 

i also have a rename button so the user can rename the files but it isn't working that well, i think i coded the rename part pretty sloppy.. here is the code i used:

 

       Dim Rename As String
       Dim Picture As String
       Picture = ListBox1.Text
       'Asks user for new name for picture
       Rename = InputBox("Type a new name for the picture and click Ok.")

       If Rename = "" Then
           Select Case Rename 'If rename is blank then give error
               Case ""
                   MessageBox.Show("Image could not be renamed. Please try again.")
           End Select

       Else
           On Error Resume Next
           System.IO.File.Copy(Application.StartupPath & "\Sidekick Files\Image Viewer\" & Picture, Application.StartupPath & "\Sidekick Files\Image Viewer\" & Rename & ".bmp")
           System.IO.File.Delete(Application.StartupPath & "\Sidekick Files\Image Viewer\" & Picture)
           ListBox1.Items.Remove(Picture)
           ListBox1.Items.Add(Rename & ".bmp")
           'Loads the Click a Image/Help page in browser.
           AxWebBrowser1.Navigate(Application.StartupPath & "\Sidekick Files\Click a Image.htm")
           MessageBox.Show("Image has been renamed to " & Rename & ".bmp")
End If

 

i couldnt figure out how to have it detect the current extention so i just put .bmp for it which doesnt work for any other image types.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...