![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Execute error: Type Mismatch: 'Execute' Hello all, I'm in the process of writing a vbscript that uses KixForms as a GUI frontend. According to a number of web pages (and this group) it is possible to to use it as follows; Set System = CreateObject("KiXtart.System") Set Form1 = System.Form() Set Button1 = Form1.Controls.Button Button1.Text = "Close" Button1.OnClick = "WScript.Quit" Set Label1 = Form1.Controls.Label Label1.Text = "Hello World!" Label1.Location = System.Point(12, 9) Form1.Visible = "True" Do While Form1.Visible Execute(Form1.DoEvents) Loop This works properly, when the Button1.OnClick is pressed it just exits however, if I try and create a function that is called when the button is clicked i.e. Set Form = CreateObject( "Kixtart.Form" ) Set Button = Form.Button Button.Text = "Close" Button.OnClick = "Func_Quit" Form.Show Do While Form.Visible Execute(Form.DoEvents) Loop Function Func_Quit MsgBox "Just a message box" wscript.echo "Function has been called" End Function The script works fine _however_ if I comment out the MsgBox line, the script displays the "Function has been called" line and then errors with the following line. Microsoft VBScript runtime error: Type mismatch: 'Execute' I've tried to do some debugging and the error occurs when the script returns to the Execute line. Please can someone explain what's happening and why it's failing Many thanks, Martin. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Execute error: Type Mismatch: 'Execute' "kellym@xxxxxx-global.co.uk" wrote: Quote: > I'm in the process of writing a vbscript that uses KixForms as a GUI > frontend. > According to a number of web pages (and this group) it is possible to > to use it as follows; > > ... > Do While Form1.Visible > Execute(Form1.DoEvents) > Loop According to the VBS docs http://msdn.microsoft.com/en-us/libr...d2(VS.85).aspx the Execute *statement* will execute a *string*, only. So unless Form1.DoEvents is a string, I don't see how that code works, at all. Perhaps you could try MsgBox Form1.DoEvents to see what string Execute is attempting to work with? ******** A couple of minor points (that shouldn't affect the way the code runs): (1) You are doing Form1.Visible = "True" But the Visible property is a BOOLEAN value, *not* a string. Yes, VBS will convert the string to boolean for you, but it would be better to code Form1.Visible = True (2) You should not use parentheses with the EXECUTE statement. They don't hurt, because any expression is still an expression when enclosed in parens, but they can have weird side effects in other usages. So just as a matter of practice, avoid them where they aren't required. ****************** This is *PURELY* a hunch on my part, but I can't help but wonder if you shouldn't simply eliminate the EXECUTE and do Do While Form.Visible Form.DoEvents Loop |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Execute error: Type Mismatch: 'Execute' On Aug 20, 7:52*pm, Old Pedant <OldPed...@xxxxxx> wrote: Quote: > "kel...@xxxxxx-global.co.uk" wrote: Quote: > > I'm in the process of writing a vbscript that uses KixForms as a GUI > > frontend. > > According to a number of web pages (and this group) it is possible to > > to use it as follows; Quote: > > ... > > Do While Form1.Visible > > * *Execute(Form1.DoEvents) > > Loop > Ummm...I'm more than a little confused here. > > According to the VBS docs > * *http://msdn.microsoft.com/en-us/libr...d2(VS.85).aspx > the Execute *statement* will execute a *string*, only. > > So unless Form1.DoEvents is a string, I don't see how that code works, atall. > > Perhaps you could try > * * *MsgBox Form1.DoEvents > to see what string Execute is attempting to work with? > When the script is run it loops around the do while loop waiting for something to happen to the Form.DoEvents object. If the button is clicked it returns the value of the Button.OnClick, which in this case is Func_Quit. I modified the script slightly so that it will display what Form.DoEvents is returning; Do While Form.Visible func = Form.DoEvents wscript.echo func Execute(func) Loop If the button is clicked, the following is displayed on the console; Func_Quit <- Function name being called Function has been called <- Result of function being called. This demonstrates that the function name is returned by the DoEvents and it is called by the Execute command. I've tried what you suggested earlier without success, one can click the button but nothing happens.; Do While Form.Visible Form.DoEvents Loop What I want the script to do is to call the function, run it and then return to the loop Am I missing something fundamental about the execute statement ? Thanks, Martin. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| I can't execute my own executable | .NET General | |||
| Can't execute 'CEC_MAIN.exe | Vista General | |||
| Execute installutil.exe | PowerShell | |||
| command : execute | Vista General | |||
| Can't execute T-SQL query | PowerShell | |||