cancel
Showing results for 
Search instead for 
Did you mean: 

How can I check a function return type in another function in vb script.

SOLVED
Highlighted
Regular Contributor

How can I check a function return type in another function in vb script.

How can I check a function return type in another function in vb script.

like there are 2 function.Kindly check below

 

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

    Else

        log.message("not ok")

    End IF

End Function

 

 

Function B()

     .....In this function i want to check status of function A... It's true or False----

so I can return value in boolean and check the same

End Function

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: How can I check a function return type in another function in vb script.

Um... OK, so that's some basic VBScripting there.  Simply...

 

Function A()

     Set obj = ----------something here-----
     A = Obj.Exists

End Function

And then, in function B

 

Function B()

     If A then
          Log.Message("Object exists")
     else
          Log.Message("Object does not exists")
     End If
End Function

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
Contributor

Re: How can I check a function return type in another function in vb script.

You can try below scenario and check if it works for you

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

         strResult=TRUE

    Else

        log.message("not ok")

       strResult=FALSE

    End IF

   A=strResult

End Function

 

Function B()

  strResult=A()

   If strRESUlt=TRUE Then

      log.Message"True"

Else

     log.Message"False"

End Function

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: How can I check a function return type in another function in vb script.

Um... OK, so that's some basic VBScripting there.  Simply...

 

Function A()

     Set obj = ----------something here-----
     A = Obj.Exists

End Function

And then, in function B

 

Function B()

     If A then
          Log.Message("Object exists")
     else
          Log.Message("Object does not exists")
     End If
End Function

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
Contributor

Re: How can I check a function return type in another function in vb script.

You can try below scenario and check if it works for you

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

         strResult=TRUE

    Else

        log.message("not ok")

       strResult=FALSE

    End IF

   A=strResult

End Function

 

Function B()

  strResult=A()

   If strRESUlt=TRUE Then

      log.Message"True"

Else

     log.Message"False"

End Function

View solution in original post

Community Hero

Re: How can I check a function return type in another function in vb script.

Hi,

 

> How can I check a function return type [...]

so I can return value in boolean and check the same

 

I am pretty sure that @tristaanogre and @rajulapati provided you with the answer you was looking for.

But been a naughty old-school guy I can't but clarify:

Considering your example and function A():

-- Return type of function A() is of boolean type. To be perfectly correct, the return type of A() is OleVariant of boolean subtype. VarType() is the function that returns the subtype of the tested object/variable. All functions and variables in scripting languages (in VBScript) are of OleVariant type.

-- As function A() is expected to return the boolean *type*, the returned *value* can be either True or False.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
Community Hero

Re: How can I check a function return type in another function in vb script.

I am pretty sure that @tristaanogre and @rajulapati provided you with the answer you was looking for. But been an old-school naughty guy I can't but clarify:
The snark is strong with this one.

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Manager

Re: How can I check a function return type in another function in vb script.

Thank you everyone. A lot of great suggesions to choose from hereSmiley Happy

 

Hi @kaiiii, which one works for you best? 


Sonya Mihaljova
Community and Education Specialist

 Join the virtual SmartBear Connect user conference on April 27-28! Get your free virtual ticket today!