Re: passing control names
Just do something like
Code:
Sub CheckIt (Param1 as Control, Param2 As Control)
Re: passing control names
Can you give a more specific detail? It is something I am not used to at all.
Re: passing control names
Using Aio's code above, you would probably do something like this (not sure if it will work though.) I've done something similar in the past, but it was quite a few years ago and I can't find the code.
Code:
Public Sub CheckIt (ByRef Param1 as Control, ByRef Param2 As Control, ByRef Param3 as Control)
dim ctlName as string
dim procName as string
ctlName = Param3.Name
procName = ctlName & "_Change(0)"
call procName
End Sub
Then you would just call CheckIt and pass in the control names.
Re: passing control names
Here is the working sample for you:
Code:
Private Sub Form_Load()
CheckIt Command1, Command2, "Text1_Change"
End Sub
Public Sub CheckIt(Param1 As Control, Param2 As Control, ProcToCall As String)
If Param1.Value = Param2.Value Then
CallByName Me, ProcToCall, VbMethod
Param2.Value = Param1.Value + 1
Else
Param2.Value = 0
End If
End Sub
Public Sub Text1_Change()
MsgBox "This block is called using CallByName"
End Sub
But I didn't understand what are you going to achieve with checking and incrementing values of command button!
Re: passing control names
Thnaks, but none of these hints seem to work..any thoughts? The last one use "ME" is this correct?
Re: passing control names
ok, please try to post that part of your codes and let's see. maybe me misunderstood the purpose of your codes.
Re: passing control names
Quote:
Originally Posted by normnov
Thnaks, but none of these hints seem to work..any thoughts? The last one use "ME" is this correct?
'Me' is used to refer to current form which contains the method.
CallByName requires the object name and its method to call. As I have written the sub as public, I have used it as member of 'Me'.
And I think this is what you are looking for!
Does this make any sense?