Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VBScript - How to get the Function return value
#3
Solved: 10 Years, 9 Months ago
assign to the FunctionName the returnedValue, for e.g. if:

Code:
Public Function DateConversion
    Set DateConversion = New QTPDateConversion
End Function

Class QTPDateConversion

' the function is converting the Todays computer's date to the date format: "1YYMMDD"
    Function TodaysDate
        ' SystemDate contains the current system date from the computer.
            SystemDate = Date
        ' adding one more day to output current date, if CurrentDate = 18, output will be 19
            'strNewDate = DateAdd("d", 1, SystemDate)
        ' converting date to a string ( will be something like e.g. (depends on system date): 02192010 -> ddmmyyyy
            fctReturn = Cstr(SystemDate)
        ' LeftString contains first two elements, from the "02192010" string -> 02
            LeftString = Left(fctReturn, 2)    ' date
        ' MidString contains the next 2 chars starting with the 3rd char.
            MidString = Mid(fctReturn, 4, 2)    ' month
        ' Returns the last two chars from the "02192010" string -> 10
            RightString = Right(fctReturn, 2)    ' year (two numbers)
        ' converting the string into the format we need it
            ConvertedDate = "1" & RightString & MidString & LeftString    ' format = 1100923

        ' assigning the output value
        TodaysDate = ConvertedDate
    End Function
End Class

To call this function we will use next:
DateConversion.TodaysDate

DateConversion = class' name
TodaysDate = function's name
Reply


Messages In This Thread
RE: VBScript - How to get the Function return value - by lotos - 09-13-2010, 04:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Childobject return wrong checkbox count.. VpnQTP 1 2,574 04-09-2015, 09:07 PM
Last Post: babu123
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,777 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  SQL on oracle database doesn't return a value Bluefields 2 3,063 07-09-2012, 01:23 PM
Last Post: Bluefields
  Return reusable object HelenN 0 4,203 04-20-2011, 08:31 PM
Last Post: HelenN
  Calling a JS function which is externally located using a VBScript Func in QTP HishSingalaxana 0 2,843 11-09-2010, 11:02 AM
Last Post: HishSingalaxana

Forum Jump:


Users browsing this thread: 1 Guest(s)