Checkbox visible/invisible

Libre 6 on Bionic Bunny I found the following code snippet on an OO forum but cant seem to make it work on LO Can somebody “translate” it into LO Basic

Function Hide_Named_CheckBox(ChkCondition as integer, ChkBoxName as string) as string

 Dim oDoc As Object
 Dim oSheet As Object
 Dim oDrawPage As Object
 Dim oForm As Object
 Dim oControl_1 As Object

oDoc = ThisComponent
oSheet = oDoc.GetCurrentController.Activesheet
oDrawPage = oSheet.DrawPage 
oForm = oDrawPage.getForms().getByIndex(0)
oControl = oForm.getByName(ChkBoxName)

  if ChkCondition = 1 then
    oControl.EnableVisible = false
    Hide_Named_CheckBox = "Invisible"
  else
    oControl.EnableVisible = true 
    Hide_Named_CheckBox = "Visible"
  end if

end function

but cant seem to make it work on LO

What could that mean? do you say that it gives you errors? which? on which data? with which LO version (“Libre 6” is not a valid version number)?

I am using LO 6 on Bionic Bunny
At the line: oControl=oForm.GetByName(ChkBoxName)
I get"Basic Runtime error Argument not optional"

(Most likely you are trying to EXECUTE a function (run it without parameters), and not CALL it)

Write the name of the checkbox in A1, write in A2 zero, write the formula in A3

=HIDE_NAMED_CHECKBOX(A2;A1)

Make sure the form is not in design mode.

Design mode

Now change value in A2, set 1 or 2 or again zero and see result

Upd. See example VisibleChkBox.ods

I copy and pasted the function as posted but I get#Name? in A3. This on a computer that is running OO 4 and not LO

See example in my answer