Basic statement to assign a value to a form control gives error msg

“BASIC runtime error. An exception occurred Type: com.sun.star.lang.IllegalArgumentException Message: arguments len differ!.” Both type Integer–any suggestions?
I’m trying to select an item from a list box and transfer that value to a field in a table. Code follows:

Option Explicit
Global oForm, oControl As Object
Global ShowInt as Integer

Sub SetControlStr(FrmNam, CntrlNam, NewStr As String)
	oForm = ThisComponent.DrawPage.Forms.GetByName(FrmNam)
	oControl = oForm.GetByName(CntrlNam)
	oControl.SetPropertyValue(NewStr)
End Sub 

Sub SetControlInt(FrmNam, CntrlNam As String, NewInt As Integer)
	oForm = ThisComponent.DrawPage.Forms.GetByName(FrmNam)
	oControl = oForm.GetByName(CntrlNam)
	oControl.SetPropertyValue(NewInt)
End Sub

Sub ExecuteAction_AccountListBox
oForm = ThisComponent.DrawPage.Forms.GetByName("LogQueryForm1")
oControl = oForm.GetByName("lstAccountListBox")
ShowInt = oControl.ValueItemList(oControl.SelectedItems(0))
MsgBox ShowInt,0,"AccountListBox" 'Just for debugging
IF ShowInt = 1 Then 'New Account
		Call SetControlStr("LogQueryForm1", "fmtAccountID", "")
		Call SetControlStr("LogQueryForm1", "txtAccountCompany", "")
		Call SetControlStr("LogQueryForm1", "txtAccountNbr", "")
		Call SetControlStr("LogQueryForm1", "txtAccountTyp", "")
		Call SetControlStr("LogQueryForm1", "txtAcctDescrit", "")		
	Else 'Transfer list AccountID to AcctID
		Call SetControlInt("LogQueryForm1", "fmtAcctID", ShowInt) ' <-- Error comes here
	EndIf
End Sub

(edit: added code section tags)

First, please learn how to use the controls for preformatted text. Your question was difficult at best to read.

Sub SetControlInt(FrmNam, CntrlNam As String, NewInt As Integer)
  oForm = ThisComponent.DrawPage.Forms.GetByName(FrmNam)
  oControl = oForm.GetByName(CntrlNam)
  oControl.SetPropertyValue(NewInt)
End Sub

setPropertyValue doesn’t know what value you are setting. There are many properties for a control. What you want is:

 oControl.Text = NewInt

Now this depends upon what you are going to do with this control. If it is going to be used to update a table it won’t work. In this case you must use the View of the control:

Sub SetControlInt(FrmNam, CntrlNam As String, NewInt As Integer)
    Dim CtlView as Object
    Dim DocCtl as Object
    oForm = ThisComponent.DrawPage.Forms.GetByName(FrmNam)
    oControl = oForm.GetByName(CntrlNam)
    DocCtl = ThisComponent.getCurrentController()
    CtlView = DocCtl.getControl(oControl)
    CtlView.Text = NewInt
 End Sub

Then you must actually tab through the field for it to be accepted for an update.

  1. Thanks, Ratslinger! Your code works exactly as you describe.
  2. Regarding “preformatted text” issue with the code: I’m using Mac, OS X 10.11.6, Firefox 47.0.1, and Libreoffice 5.1.4.2. I cut the code out of the Libreoffice macro editor, and pasted it into the ask.libreoffice question window. It was beautifully formatted in the macro editor, and in the question window. Then when I pressed the “Submit” button it showed as all run together. Is there a way to prevent this?

Note: exactly the same happened to the above comment. I had comment (1) and (2) on separate lines, separated by a blank line.

As far as the text, it appears you didn’t use the toolbar icon for inserting the text. You can see in my answer the gray boxes the code is in. Also I believe there is a preview window where you can view you input as it will be displayed.

OK, thanks again! I see an icon that says 101 010, and hovering the mouse it says “preformatted text” – didn’t know what that was for.