Results 1 to 9 of 9
  1. #1

    execute statement

    I'm trying to create constants as part of a run using the execute statement and just can't get the syntax happening - brain freeze?

    this is what i want to define
    Public Const UserName = "scitest015"

    but how can I get it to work using the execute command?
    Execute "Public Const UserName = "scitest015""

  2. #2

  3. #3

    Re: execute statement

    so would this define a constant when I want it ?

  4. #4

    Re: execute statement

    Joe, it will.

    You can execute this in QTP:

    <font class="small">Code:</font><hr /><pre>
    Execute "Public Const UserName = ""scitest015"""
    MsgBox UserName

    'This line will throw an error because UserName has already been defined as a constant
    UserName = "J"
    </pre><hr />

    Anshoo Arora
    Relevant Codes

  5. #5

    Re: execute statement

    so how would I be able to "undefine" so I can "redefine" it?

  6. #6

    Re: execute statement

    You cannot change a constant after its initialization.. It cannot be redefined.

    Anshoo Arora
    Relevant Codes

  7. #7

    Re: execute statement

    [ QUOTE ]
    so how would I be able to "undefine" so I can "redefine" it?

    [/ QUOTE ]
    Why would be that be a constant? A constant by property should only be defined once and not re-defined

  8. #8

    Re: execute statement


    I only need to set them up at start of test - so it is a constant but it needs to be flexible (bosses orders...)

    so I tried this and can't get the parentheses again...

    I did read the link

    Execute "Public Const " &amp; oSheet.rows(constantrow).Columns(1).Value " = " &amp; oSheet.rows(constantrow).Columns(2).Value """

  9. #9

    Re: execute statement

    ok fiddled with it and got it to work!

    thanks for the links (I read it slowly this time!)
    Execute "Public Const " &amp; oSheet.rows(constantrow).Columns(1).Value &amp; " = " &amp; oSheet.rows(constantrow).Columns(2).Value &amp; ""



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:39 PM.

Copyright BetaSoft Inc.