# Visual Basic > Visual Basic .NET >  I can't seem to get my icon files to work in my project correctly in my.resources

## nwl5

I'm using Visual Studio 2022 Community Edition

When trying to add some icon files to the resources folder and using this code to change the background image of button 10 when clicked:

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        PictureBox2.Visible = True
        PictureBox3.Visible = True
        Label1.Visible = True
        Label3.Visible = True
        Button10.BackgroundImage = My.Resources_3
    End Sub

I get error BC30456: 'Resources_3 is not a member of WinFormsApp1.My. When I check the resources folder in the solution explorer 3.ico is there and in theory, should allow me to use it in my code but it's not. It will allow me to use any other icons I have uploaded to the resources folder in the past. However, my code won't even acknowledge any other icons I have uploaded recently.

----------


## jmcilhinney

You shouldn't need to look in the Resources folder. VS will maintain that automatically. You just need to look at the Resources page of the project properties. Did you add the file there or not? If so then you can access it via My.Resources, but there is no such thing as My.Resources_3. Identifiers cannot start with a number so a leading underscore has probably been added. That means that you would use My.Resources._3 in code. Of course, you shouldn't need the underscore at all because you should have changed the name to something descriptive. ALWAYS use descriptive names for everything.

----------


## schoemr

I think it should be:



```
Button10.BackgroundImage = My.Resources.Resources_3
```

----------


## jmcilhinney

> I think it should be:
> 
> 
> 
> ```
> Button10.BackgroundImage = My.Resources.Resources_3
> ```


I suspect not. The file that was added is named '3.ico' so, unless the resource itself was renamed to 'Resource_3' by the OP, there's no reason it would have that name. When you add a file as a resource, a property is added to the My.Resources.Resources module with the same name as the file. As I said, identifiers (i.e. names of types, members and variables) cannot start with a digit character so the system would prepend an underscore to such a property, so it would be 'My.Resources.Resources._3'. Because those properties are members of a module, you can omit the module name when referring to them, so 'My.Resources._3'. I could be wrong but that seems the most logical possibility to me.

Like I said though, the OP really should change the resource names so that they are meaningful. For instance, if this icon contains an image of the number 3, I'd tend to name it 'Number3Icon' or the like. Anyone reading that, including the OP in a few months when they've forgotten the hell they were doing in this project, will have a very good idea of what it's for just from that name, where just '3' could be anything.

----------


## schoemr

I suspect so..

----------


## jmcilhinney

> I suspect so..


I guess we'll see. Drumroll please...  :Wink: 

Either way, the OP should really be paying attention to Intellisense when it tries to tell them something. There's obviously no way that Intellisense display 'Resources_3' as an option after typing 'My.', so it really shouldn't be a surprise that the compiler tells you that that is not valid.

----------


## nwl5

Ok so after a few days of playing with it, it turns out that my icon files were in a format that has not been used since windows 98. I had originally planned to write this program in visual basic 6 but then suddenly decided to use vs 2022 instead. I converted all the old icon files to jpg and everything seems to be working properly now.

----------


## nwl5

You are definitely right. I do need to do better with naming my controls. I tend to be lazy when it comes to that and then wonder what the hell I did later lol.

----------


## jmcilhinney

> Ok so after a few days of playing with it, it turns out that my icon files were in a format that has not been used since windows 98. I had originally planned to write this program in visual basic 6 but then suddenly decided to use vs 2022 instead. I converted all the old icon files to jpg and everything seems to be working properly now.


None of that really follows by what you said in post #1. Windows still uses ICO files. I'm not aware of there being ICO files that were valid in Windows 98 that are no longer valid but it's possible there's something I'm unaware of. If you add a valid ICO file as a resource then the My.Resources property will be type Icon, whereas if you add a JPG file it will be type Image. Icons are used in various places in WinForms, including on form title bars and NotifyIcons.

No matter what type of file you added, _My.Resources_3_ would not be valid. _My.Resources_ is a namespace and that contains a module named Resources. Each resource you add is exposed via a property of that module. If you added a file named _3.jpg_, you'd still have to access the Image resource via _My.Resources._3_ or whatever you changed the name to.

----------

