|
-
Oct 25th, 2006, 07:46 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Changing the option of a variable
Hi all,
I'm making a program, and it has 8 buttons. Since each of the buttons needs to have a very similar set of code attatched to it (differing only by the button number), I thought I might save some code-space and shorten it by having each of the buttons simply set a global variable with the number, and call a public function. The button code(s) are:
Code:
Private Sub Slot1_Click()
DrinkRef = 1
Call CallDrink
End Sub
The function "CallDrink" then has to make a comparison to see if the picture in a certain picturebox matches another, standard picture. Each button has it's own picture. I tried to do this by concatenating the name of the image by taking a variable and adding the beginning part of the string, the number, and the last part (the button's name):
Code:
Public Function CallDrink()
Dim WordCombine As String
WordCombine = "Slot" & DrinkRef & "LED"
If WordCombine.Picture = LightOn.Picture Then
MsgBox "Hi"
End If
End Function
For example, if the button clicked was "1", the DrinkRef would be "1", and therefore WordCombine would be: "Slot" & 1 & "LED", or "Slot1LED", which is the button's name.
However, I cannot do "WordCombine.Picture", as WordCombine is just a basic string. Is there a way I can get around the phrasing of this so I can make this work? If not, no worries, I'll just put the code into each seperate button.
Thanks!
Last edited by BubbleLife; Oct 26th, 2006 at 09:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|