08-20-2013, 03:07 AM
(This post was last modified: 08-20-2013, 03:52 AM by nakulgupta18.)
1. How a function can return two values.? write the code for the function.. ?
2. compare two date "10/10/2013" and "10-octomber-2013" and return true or false.?
Code:
'''using two output parameters while defining a function
'' defining function with one input and two output parameters
Function TwoValues(inVal, outVal1, outVal2)
'''' processes
''....
''....
''assigning values to output parameters
outVal1 = 1234
outVal2 = 2222
End Function
''calling the function
TwoValues x, y, z
MsgBox y
MsgBox z
Code:
'''using arrays
Function TwoValues()
TwoValues = Array("abcd", "efgh")
End Function
x = TwoValues()
MsgBox x(0)
MsgBox x(1)
2. compare two date "10/10/2013" and "10-octomber-2013" and return true or false.?
Code:
date1 = "10/10/2013"
date2 = "10-october-2013"
dateArray1 = Split(date1, "/", -1, 1)
dateArray2 = Split(date2, "-", -1, 1)
If dateArray1(0) = dateArray2(0) And _
UCase(MonthName(dateArray1(1))) = UCase(dateArray2(1)) And _
dateArray1(2) = dateArray2(2) Then
MsgBox True
Else
MsgBox False
End If