Search code examples
.netvb.netvisual-studio-2005embedded-resource

Create a Icon from a Resources.resx


I have a Icon(.ico file) in the (VB.NET)MyProject>Resources.resx file.

How do I extract it in run-time as a Icon object?

Thanks


Solution

  • You should be able to do the following:

    Dim myIcon as Icon = [Your Project Namespace].Properties.Resources.[icon name]
    

    It should pop up with Intellisense.

    NOTE: My VB is a bit rusty and I've been using VS 2008 for quite some time, so my apologies if this isn't quite right in syntax or not the way to do it in VS 2005.

    UPDATE: Apparently the VB way of accessing [Your Project NameSpace].Properties is to use the My keyword:

    Dim myIcon as Icon = My.Properties.[icon name]