CodeWidgets.com: Online Source Code Library: C#, ASP, ASP.NET, VB, VB.NET, VB Script, Microsoft Access, Excel, JavaScript, J Script, XML, VBScript, Website Design, DevExpress Components, Reporting, Application and Website Templates.

Widget #CS0055

Create a function that returns multiple values. VB.Net

Free

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

Last Updated: 4/27/2018


Related Widgets 
Price 
# 
CS0002 Adding a Default value of zero in a lookup Query (SQL Server)$0.00Add To Cart
CS0159 Databound Collapsible Grid (ASP.NET, VB.Net)$20.00Add To Cart
CS0197 Storing a DataSet in a Session Variable (ASP.NET)$0.00Add To Cart

Recently Viewed Widgets 
Price 
# 
No data to display

Collapse/Expand
Format

Plug & Play Code

Copy the Source Code Above..


Collapse/Expand
License

License

No Restrictions

Re-Distribution Permitted
This source code is provided to you "as is" without warranty
CLICK HERE FOR TERMS OF USE
Copyright 2000-2006 Comrie Software Solutions


This website uses Cookies to store User information and Shopping Cart Items for the duration of your visit to CodeWidgets.com.

No Credit Card or Financial information is stored by CodeWidgets.com. Click Here For Our Complete Privacy Policy and Terms of Use.

I Understand