Hi,

I have a simple query but im just not able to get it right.

Have a look at my sample code below

Sub Function1

My Code Here
Function2(Year,Month)

End Sub

Sub Function2(Year,Month)
Dim Str as String()

for 1 to 30
Dim MyDate As New Date(Year, Month, i)
Str = MyDate.DayOfWeek.ToString()
Next
Return Str

End Sub

Function 2 Is used to get the Name of the Day.

Year and Month Parameter is Passed from Function 1 like this Function2(Year,Month)

My issue is

1)i want to add names of all the 30 days into one array

2)How can i return that array to Function1

3)Howe can i use that Array in Function 1 and assign each name to individual variable.

Please Suggest

Check this out:

Private Shared Sub Main(args As String())
	Dim [date] As DateTime = DateTime.Today
	Dim daysNames As String() = GetDaysNames([date])
			'use each day (or show it)
	For Each days As String In daysNames
	Next
End Sub

Private Shared Function GetDaysNames([date] As DateTime) As String()
	Dim daysInMonth As Integer = DateTime.DaysInMonth([date].Year, [date].Month)
	Dim daysNames As String() = New String(daysInMonth - 1) {}

	'do your code to fill the daysNames array

	'on the end:
	Return daysNames
End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.