While calling sub procedure its giving error - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: While calling sub procedure its giving error (/Thread-While-calling-sub-procedure-its-giving-error) |
While calling sub procedure its giving error - Akhila - 10-21-2012 Hi There, I had written the following simple VB script. while calling sub procedure its giving type mismatch with the line "msgbox "val is" & result"....where did I make the mistake? Code: Sub result(val) Thanks, [/b] RE: While calling sub procedure its giving error - harishshenoy - 10-22-2012 Hi , Sub procedure will not return any value , so you will not be able to call it and expect a return result out of it. You have to use the 'function' instead to return the value. U can give directly the 'function name' to return any value. I have modified your code try out: Code: Function result(val) ***Here I have converted the input box entry to 'Cint' because VB script only uses a variable called 'Varient' , you have convert it to integer using 'cint'. **Also i have assigned the 'msgbox' value directly to the function name to make your function returns some value. **** You have to use 'call' statement while calling a 'sub' , but it is not mandatory in case of 'function' call. Thanks, Harish |