So I created a subroutine to do some work but now i have no idea how to pass the results on to another stage in the process.

Private Sub CheckDates() Handles MyBase.Load

        Dim Duedate As Date = INFDateLabel1.Text
        Dim Duedate2 As Date = INFDateLabel2.Text
        Dim Duedate3 As Date = INFDateLabel3.Text
        Dim Duedate4 As Date = INFDateLabel4.Text
        Dim Duedate5 As Date = INFDateLabel5.Text
        Dim Duedate6 As Date = INFDateLabel6.Text
        Dim Duedate7 As Date = INFDateLabel7.Text
        Dim Duedate8 As Date = INFDateLabel8.Text
        Dim Duedate9 As Date = INFDateLabel9.Text
        Dim Duedate10 As Date = INFDateLabel10.Text

        DateCalc(Duedate)
        DateCalc(Duedate2)
        DateCalc(Duedate3)
        DateCalc(Duedate4)
        DateCalc(Duedate5)
        DateCalc(Duedate6)
        DateCalc(Duedate7)
        DateCalc(Duedate8)
        DateCalc(Duedate9)
        DateCalc(Duedate10)

    End Sub

    Private Sub DateCalc(ByVal duedate As Date)
        Dim Span As TimeSpan
        Dim Day As Integer

        Span = Now.Subtract(duedate)
        Day = Span.Days
        MsgBox(Day)

        Record1(Day)

    End Sub

I'm using the msgbox to see that the subroutine is actually performing its job and it is, but i have no idea how to pass the individual results on to the next stage in my prog which are individual controls that use the results for their functioning. It does turn out that the code even for just one of the controls doesn't seem to work....what am i doing wrong?

Private Sub Record1(ByVal Day As Integer)

        Green1.BackColor = Color.Gray
        Yellow1.BackColor = Color.Gray
        Red1.BackColor = Color.Gray

        If Day >= 4 Then
            Green1.BackColor = Color.Green
        ElseIf Day >= 2 Then
            Yellow1.BackColor = Color.Yellow
        ElseIf Day = 0 Then
            Red1.BackColor = Color.Red
        End If

    End Sub

Any help would be appreciated.

You need to use a Function that returns the type you want.

http://www.homeandlearn.co.uk/net/vbnet.html

Private Function DateCalc(ByVal duedate As Date) As Date        
        Dim Span As TimeSpan
        Dim Day As Integer

        Span = Now.Subtract(duedate)
        Day = Span.Days
        MsgBox(Day)

        Return Day
    End Function

Use it like this

INFDateLabel1.Text = CStr(DateCalc(Duedate))

This should get you on your way

I don't know where you're getting your dueDates from but you should look into loops.

You have to change "As Date" in your function def to "As Integer" to correspond with the defined type of the variable "Day" or you will get an error.

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.