How to use a String Array for passing Values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SEhtesham
    New Member
    • Aug 2011
    • 45

    How to use a String Array for passing Values

    Hi,

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

    Have a look at my sample code below
    Code:
    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
  • !NoItAll
    Contributor
    • May 2006
    • 297

    #2
    Code:
    Dim str() as String
    Dim MyDate as Date
    for 0 to 30
        Redim Preserve str(i)
        try
            Str(i) = MyDate.DayOfWeek.ToString()
        Catch
            Exit For
        End try
    Next
    
    Return Str
    Check the str.length to see how many days you have - not all months have the same number of days...

    Comment

    Working...