Exforsys
+ Reply to Thread
Results 1 to 8 of 8

Error in QTP

This is a discussion on Error in QTP within the Software Testing forums, part of the Testing category; Hi. I am having some problems with the following code. _________________________________________________ Dim Count Dim BankCount BankCount = Int (DataTable.Value("A", dtGlobalSheet)) ...

  1. #1
    abuzzi is offline Junior Member Array
    Join Date
    Dec 2007
    Answers
    2

    Talking Error in QTP

    Hi.

    I am having some problems with the following code.
    _________________________________________________
    Dim Count
    Dim BankCount

    BankCount = Int (DataTable.Value("A", dtGlobalSheet))

    Count = 0

    Do until Count = BankCount

    Count = Count +1
    msgbox Count
    msgbox BankCount

    wait 1

    Loop
    _________________________________________________

    The script runs successfully, however when the scripts Count = Bankcount, the execution cycle is looping back to the beginning of the script, and produces the following error.

    Error:
    Type mismatch: '[string: ""]'

    Details:
    Line (4): "BankCount = Int (DataTable.Value("A", dtGlobalSheet))".


    Could someone please tell me:

    1 - Why the script loops back to the beginning once Count = BankCount
    2 - Why an error is being returned on the above line of code only on the second pass / why no error is returned on the above line of code on the first pass .. ??

    Looking forward to seeing your thoughts / suggestions / script alteration recommendations ...
    thanks - and happy new year


  2. #2
    sukanya_QTP is offline Junior Member Array
    Join Date
    Apr 2008
    Answers
    8
    Quote Originally Posted by abuzzi View Post
    Hi.

    I am having some problems with the following code.
    _________________________________________________
    Dim Count
    Dim BankCount

    BankCount = Int (DataTable.Value("A", dtGlobalSheet))

    Count = 0

    Do until Count = BankCount

    Count = Count +1
    msgbox Count
    msgbox BankCount

    wait 1

    Loop
    _________________________________________________

    The script runs successfully, however when the scripts Count = Bankcount, the execution cycle is looping back to the beginning of the script, and produces the following error.

    Error:
    Type mismatch: '[string: ""]'

    Details:
    Line (4): "BankCount = Int (DataTable.Value("A", dtGlobalSheet))".


    Could someone please tell me:

    1 - Why the script loops back to the beginning once Count = BankCount
    2 - Why an error is being returned on the above line of code only on the second pass / why no error is returned on the above line of code on the first pass .. ??

    Looking forward to seeing your thoughts / suggestions / script alteration recommendations ...
    thanks - and happy new year
    do wat? u have to give some statements or funtion to do before until statement


  3. #3
    Noorjahan is offline Junior Member Array
    Join Date
    Jul 2008
    Answers
    9
    Hi Abuzzi,

    You have given the Msgbox right within the loop.. What is the value getting displayed that time??

    Is it coming correctly?


  4. #4
    kavita_murala is offline Junior Member Array
    Join Date
    Aug 2007
    Answers
    2
    Hi,
    U plz try with this code as it can take u for infinite loop

    BankCount = DataTable.Value("A", dtGlobalSheet)

    regards,
    Kavita


  5. #5
    RayOMan is offline Junior Member Array
    Join Date
    Jan 2009
    Answers
    1
    Quote Originally Posted by kavita_murala View Post
    Hi,
    U plz try with this code as it can take u for infinite loop

    BankCount = DataTable.Value("A", dtGlobalSheet)

    regards,
    Kavita
    I have encountered the same problem as the original poster.

    This code stays in an infinite loop.


    intNumRows = 1
    intMaxRows = DataTable.Value("Test", dtGlobalSheet)


    MsgBox(intMaxRows)


    Do Until intNumRows > intMaxRows
    MsgBox("In Loop: " & intNumRows)
    intNumRows = intNumRows + 1
    Loop


    This code works fine.
    intNumRows = 1
    intMaxRows = DataTable.Value("Test", dtGlobalSheet)


    MsgBox(intMaxRows)


    Do Until intNumRows > 2
    MsgBox("In Loop: " & intNumRows)
    intNumRows = intNumRows + 1
    Loop

    I don't know why the first code stays in an infinite loop.


  6. #6
    Sample123 is offline Junior Member Array
    Join Date
    Jan 2009
    Answers
    1
    Use Cint as follows,

    intMaxRows = Cint(DataTable.Value("Test", dtGlobalSheet))


  7. #7
    basanth27 is offline Junior Member Array
    Join Date
    Jul 2009
    Answers
    12
    Quote Originally Posted by RayOMan View Post
    I have encountered the same problem as the original poster.

    This code stays in an infinite loop.


    intNumRows = 1
    intMaxRows = DataTable.Value("Test", dtGlobalSheet)


    MsgBox(intMaxRows)


    Do Until intNumRows > intMaxRows
    MsgBox("In Loop: " & intNumRows)
    intNumRows = intNumRows + 1
    Loop


    This code works fine.
    intNumRows = 1
    intMaxRows = DataTable.Value("Test", dtGlobalSheet)


    MsgBox(intMaxRows)


    Do Until intNumRows > 2
    MsgBox("In Loop: " & intNumRows)
    intNumRows = intNumRows + 1
    Loop

    I don't know why the first code stays in an infinite loop.
    what does msgbox(intMaxRows) return in the first case ??


  8. #8
    rahulaamir is offline Junior Member Array
    Join Date
    Jan 2011
    Answers
    1
    Its not a problem with code...
    when you delete a value from datatable using delete key on keyborad it leaves the value as null string...
    and if your run settings is to run on all rows then the test will run for more that one time..
    now second time the problem is the its checking count(intezer) with bankcount(string) so Type mismatch: '[string: ""]' is coming...
    to solve this just go to File->settings-> Run... and make it run one iteration only...(remember when deleting from a datatable use right click ->edit->delete)


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...