VB 6.0, VB.NET
Using Structures or Types
'VB 6.0 Create a Type to store your values in
Public Type vbTwoDates
m_StartDate As Date
m_EndDate As Date
End Type
'Function to return the multiple values
Function GetDates(ByVal dtValue As Date) As vbTwoDates
'Pass values to the Members of the GetDates function declared as Type vbTwoDates
GetDates.m_StartDate = dtValue - 3
GetDates.m_EndDate = dtValue + 3
End Function
Public Sub ShowDates()
'declare a variable of the Type vbTwoDates
Dim dtTwoDays As vbTwoDates
'Fill the variable declared as vbTwoDates using the function
dtTwoDays = GetDates(Date())
'display the values
MsgBox dtTwoDays.m_StartDate & " to " & dtTwoDays.m_EndDate
End Sub
'VB.NET Create a Structure to store your values in
Public Structure
vbTwoDates
Public m_StartDate As
System.DateTime
Public m_EndDate As
System.DateTime
End Structure
'Function to return the multiple values
Function GetDates(ByVal
dtValue As System.DateTime) As
vbTwoDates
'Pass values to the Members of the GetDates function
declared as Type vbTwoDates
Dim Duration As
System.TimeSpan
Duration = New System.TimeSpan(3, 0, 0, 0, 0)
GetDates.m_StartDate = dtValue.Subtract(Duration)
GetDates.m_EndDate = dtValue.Add(Duration)
End Function
Public Sub
ShowDates()
'declare a variable of the Type vbTwoDates
Dim dtTwoDays As
vbTwoDates
'Fill the variable declared as vbTwoDates using the
function
dtTwoDays = GetDates(System.DateTime.Today)
'display the values
MsgBox(dtTwoDays.m_StartDate.ToString & " to " &
dtTwoDays.m_EndDate.ToString)
End Sub