I just started with scripting in MM. I have a question, which I just can't find an answer to.
Basically, I would like to change the caption of a label by pressing another button.
With the next code I get the OLE error: 800a01C2, followed by a mismatch error.
Can someone tell what I am doing wrong here?
tnx,
Allart
Code: Select all
Sub OnStartup
Set UI = SDB.UI
' Create the window to be shown
Set Form = UI.NewForm
Form.FormPosition = 4 ' Screen Center
Form.Caption = "Test Change labels"
Set Lbl2 = UI.NewLabel(Form)
Lbl2.Common.ControlName = "Lbl2"
Lbl2.Common.SetRect 10, 10, 100, 16
Lbl2.Caption = "Change This Label"
Set Btn2 = UI.NewButton(Form)
Btn2.Common.ControlName = "Btn2"
Btn2.Common.SetRect 10, 40, 80, 25
Btn2.Caption = "Test"
Script.RegisterEvent Btn2, "OnClick", "Btn2Click"
Form.ShowModal
SDB.Objects("Form1") = Form1
End Sub
Sub Btn2Click (Form)
Set frm1 = SDB.Objects("Form1")
Set label2 = frm1.ChildControl("Lbl2")
label2.Caption = "Label Changed"
SDB.MessageBox "Clicked Button", mtInformation, Array(mbOk)
' add code to change Caption of Lbl2
End Sub