Advertisement
iiFireKingii

Give Me Any Icon (Visual Basic)

Sep 5th, 2019
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4. Dim dlg As New OpenFileDialog
  5. With dlg
  6. .Title = "Open File"
  7. .FileName = ""
  8. .Filter = "All Files|*.*"
  9. End With
  10. If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
  11. Dim nicon As Icon = Icon.ExtractAssociatedIcon(dlg.FileName)
  12. PictureBox1.BackgroundImage = nicon.ToBitmap
  13. PictureBox1.BackgroundImageLayout = ImageLayout.Zoom
  14. End If
  15. End Sub
  16.  
  17. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  18. Dim dlg As New SaveFileDialog
  19. With dlg
  20. .Title = "Save Icon"
  21. .FileName = ""
  22. .Filter = "PNG|*.png"
  23. End With
  24. If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
  25. PictureBox1.BackgroundImage.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Png)
  26. End If
  27. End Sub
  28.  
  29. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  30.  
  31. End Sub
  32. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement