|
-
Jun 12th, 2000, 09:35 PM
#1
Hi People,
I am currently writing a Nought's and Crosses game.
I have 9 command button's for the different parts of the board. When you click a button the program calls a procedure in another module.
This Module will then place an X or a O in the Caption property of the button that called it.
I can't find out how to reference the calling button's caption. I have tried passing into the module a string with the command button's name and then saying string.caption = "X", but this does not work.
Any Idea's, Cheers ?
-
Jun 12th, 2000, 09:59 PM
#2
Fanatic Member
A couple of ideas actually.
Pass a reference of the command button to the module
Code:
'in module
private sub mySub (cmdButton as commandButton)
'do all your stuff
cmdButton.Caption = ? 'O or X
End Sub
'in button click
Private Sub cmdButton1_Click()
mySub cmdButton1
End Sub
Or return a string.
Code:
'in module
private function myFunction () as string
'do all you stuff
myFunction = ? 'O or X
End Function
'in button click
private sub cmdButton1_Click()
cmdButton.Caption = myFunction
end sub
Hope this helps.
Iain, thats with an i by the way!
-
Jun 12th, 2000, 09:59 PM
#3
transcendental analytic
Commandbuttons are objects and you pass the object reference, which could either be a commandbutton or an object, not a string.
IE:
Code:
Dim cbref as commandbutton
set cbref = yourform.yourcommandbutton
cbref.caption="X"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 12th, 2000, 10:03 PM
#4
Cheers, It think that should help me out
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
|