Windows Vista Forums

Execute error: Type Mismatch: 'Execute'
  1. #1


    kellym-global.co.uk Guest

    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 SpecsSystem Spec

  2. #2


    Old Pedant Guest

    RE: Execute error: Type Mismatch: 'Execute'



    "kellym@xxxxxx-global.co.uk" wrote:

    > 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
    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, 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 SpecsSystem Spec

  3. #3


    kellym-global.co.uk Guest

    Re: Execute error: Type Mismatch: 'Execute'

    On Aug 20, 7:52*pm, Old Pedant <OldPed...@xxxxxx>
    wrote:

    > "kel...@xxxxxx-global.co.uk" wrote:

    > > 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
    >
    > 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?
    >
    Thanks for the reply OP, to answer some of your questions;

    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 SpecsSystem Spec

Execute error: Type Mismatch: 'Execute' problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute cmd from a list bob123 VB Script 8 27 Mar 2010
Type Mismatch Error After Converting vbs to wsf kamyers1 VB Script 2 15 Mar 2010
Type Mismatch error on DNS capture... HELP please Microsoft VB Script 0 13 Nov 2009
I can't execute my own executable Radu .NET General 1 26 Mar 2009
Embedded swf does not execute Ralph W Vista mail 1 11 Jun 2007