Runescope
Well-known member
- Joined
- Jan 6, 2011
- Messages
- 53
- Programming Experience
- Beginner
So I have a series of buttons that I want the image to change when I click on them.
Here's the code I have so far:
now, the line
works fine and does what I want, but I want to be able change the images programmatically based on the button clicked. Eventually there will be 12 buttons all linking to this code and it SHOULD be able to sort it out.
For some reason the line
crashes with a "Object reference not set to an instance of an object." error. (BtnName = 'btnMainFiltIn'. I checked )
Now what's REALLY strange is that in another part of the program I have this line.:
And it works perfectly.
Soooooooooooo I'm confused. I can't figure out why one works and the other doesn't
Anyone have any ideas?
(Edit: Just a small rant. The "Object reference not set to an instance of an object." error is the most useless and generic error I have ever come across) [/rant]
Here's the code I have so far:
VB.NET:
Private Sub btnFilter_Click(sender As System.Object, e As System.EventArgs) Handles btnMainFiltIn.Click, btnHistFiltIn.Click
Dim BtnName, BtnNameF, BtnNameE As String
BtnName = sender.Name : BtnNameF = Mid$(BtnName, 1, 7) : BtnNameE = Mid$(BtnName, 8)
Select Case BtnNameE
Case "FiltIn"
btnMainFiltIn.BackgroundImage = iFilters.Images(1)
Me.Controls(BtnName).BackgroundImage = iFilters.Images(1)
Case "FiltOut"
Case "FiltOff"
End Select
End Sub
now, the line
VB.NET:
btnMainFiltIn.BackgroundImage = iFilters.Images(1)
For some reason the line
VB.NET:
Me.Controls(BtnName).BackgroundImage = iFilters.Images(1)
Now what's REALLY strange is that in another part of the program I have this line.:
VB.NET:
Me.Controls(BtnName).BackgroundImage = iCalendar.Images(3)
And it works perfectly.
Soooooooooooo I'm confused. I can't figure out why one works and the other doesn't
Anyone have any ideas?
(Edit: Just a small rant. The "Object reference not set to an instance of an object." error is the most useless and generic error I have ever come across) [/rant]
Last edited: