assign to the FunctionName the returnedValue, for e.g. if:
To call this function we will use next:
DateConversion.TodaysDate
DateConversion = class' name
TodaysDate = function's name
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