I have a dialogue with some buttons and boxes. Eight of the buttons
does basically the same thing, but to different objects, so I need to
write 8 macros for these, one for each button, since I can not call a
subroutine with parameters from a command button.

My solution right now is to let the buttons call each own subroutine,
for example the first button calls:
Sub MySub1
   MySub(1)
End Sub

So all the subroutines call MySub, but with different parameters, and
of course MySub looks something like this:
Sub MySub(X As Integer)
   Dim CtlName As String
   Dim Ctl As Object
   Ctl=Dlg.getControl("ComboBox" + LTrim(Str(X)))
   ' Well, then it's doing stuff with Ctl and so on…
End Sub

Of the easiest way would to assign the first button to MySub(1) and so
on, making 8 subroutines unnecessary, but no matter what I try it
doesn't seem like this is possible.
Another solution would be to let all the 8 buttons call this one and
only subroutine:
Sub MySub
   Dim X As String
   X=Blahblah ' The name of the last button that was pressed…
   Select Case X
   Case "CommandButton1"
      'Do something
   'And so on
   End Select
End Sub

Hm… when thinking about it, this solution is maybe not that much
convenient after all…

Suggestions?

Johnny Rosenberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to