Small Cheese

Unexpected ‘Next’ or Unexpected ‘End If’

For who has been using QTP10 (HP QuickTest Professional 10), I believe some may facing the same issue like I mention in the title. First of all, I guess I missing to put ‘Next’ or something wrong with my code, then I trace my code manually to find where is the ‘bug’. Finally I can’t find any bug and I also confirm that my script is correct and nothing wrong/missing. But why!!!!

Actually I also not too sure about it, but I find a stupid way to “fix” this error. Why I say that is a stupid solution? After you finish reading my blog then I think you should think that is funny as well.

Please look at the screenshot, after I completed the script and try to save, the QTP prompt me that there is an error (Unexpected ‘Next’, sometime happen in ‘End If’).

QTP Script With Error
QTP Script With Error

Then I remark the “For loop” and save the script. No error generated.

Remark Added
Remark Added

After the script saved, I enable the For loop by removing the remark, then save the script again.

Remark Removed
Remark Removed

Amazing! The script can be saved which is totally same as previously. This was also “unexpected” for me.

If someone know the reason , please post to share your learning so that whoever view this post will gain some knowledge. Thanks and enjoy.


Custom Search