Skip to content

TAB con días semana

January 24, 2012

Este TAB nos mostrará la fecha dentro de cada TAB, dependiendo de el día en que nos encontramos actualmente, calculando las fechas del resto de los TAB. Primero nos activa el TAB correspondiente según día de la semana en que nos encontramos:

  Private Sub diesTAB()

        ‘ Segons dia actual de setmana, dóna el nom d’aquest dia en català
        dataValue = LabelControl3.Text
        diaN = dataValue.DayOfWeek

        LabelControl20.Text = dataValue.DayOfWeek

        If LabelControl20.Text = “1” Then
            LabelControl18.Text = “Dilluns”
            TabControl1.SelectedTab = TabDill
        ElseIf LabelControl20.Text = “2” Then
            LabelControl18.Text = “Dimarts”
            TabControl1.SelectedTab = TabDim
        ElseIf LabelControl20.Text = “3” Then
            LabelControl18.Text = “Dimecres”
            TabControl1.SelectedTab = TabDix
        ElseIf LabelControl20.Text = “4” Then
            LabelControl18.Text = “Dijous”
            TabControl1.SelectedTab = TabDij
        ElseIf LabelControl20.Text = “5” Then
            LabelControl18.Text = “Divendres”
            TabControl1.SelectedTab = TabDiv
        ElseIf LabelControl20.Text = “6” Then
            LabelControl18.Text = “Dissabte”
            TabControl1.SelectedTab = TabSet
        ElseIf LabelControl20.Text = “0” Then
            LabelControl18.Text = “Diumenge”
            TabControl1.SelectedTab = TabSet
        End If

        ‘ Assigna la data actual al TAB actiu i definim les dates de la resta de dies
        Dim dataC As Date
        dataC = DatePart(DateInterval.Day, Now) & “/” & DatePart(DateInterval.Month, Now) & “/” & DatePart(DateInterval.Year, Now)

        If LabelControl20.Text = “1” Then
            lblDill.Text = dataC
            lblDim.Text = DateAdd(DateInterval.Day, CType(1, Integer), dataC)
            lblDix.Text = DateAdd(DateInterval.Day, CType(2, Integer), dataC)
            lblDij.Text = DateAdd(DateInterval.Day, CType(3, Integer), dataC)
            lblDiv.Text = DateAdd(DateInterval.Day, CType(4, Integer), dataC)
        ElseIf LabelControl20.Text = “2” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-1, Integer), dataC)
            lblDim.Text = dataC
            lblDix.Text = DateAdd(DateInterval.Day, CType(1, Integer), dataC)
            lblDij.Text = DateAdd(DateInterval.Day, CType(2, Integer), dataC)
            lblDiv.Text = DateAdd(DateInterval.Day, CType(3, Integer), dataC)
        ElseIf LabelControl20.Text = “3” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-2, Integer), dataC)
            lblDim.Text = DateAdd(DateInterval.Day, CType(-1, Integer), dataC)
            lblDix.Text = dataC
            lblDij.Text = DateAdd(DateInterval.Day, CType(1, Integer), dataC)
            lblDiv.Text = DateAdd(DateInterval.Day, CType(2, Integer), dataC)
        ElseIf LabelControl20.Text = “4” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-3, Integer), dataC)
            lblDim.Text = DateAdd(DateInterval.Day, CType(-2, Integer), dataC)
            lblDix.Text = DateAdd(DateInterval.Day, CType(-1, Integer), dataC)
            lblDij.Text = dataC
            lblDiv.Text = DateAdd(DateInterval.Day, CType(1, Integer), dataC)
        ElseIf LabelControl20.Text = “5” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-4, Integer), dataC)
            lblDim.Text = DateAdd(DateInterval.Day, CType(-3, Integer), dataC)
            lblDix.Text = DateAdd(DateInterval.Day, CType(-2, Integer), dataC)
            lblDij.Text = DateAdd(DateInterval.Day, CType(-1, Integer), dataC)
            lblDiv.Text = dataC
        ElseIf LabelControl20.Text = “6” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-5, Integer), dataC)
            lblDim.Text = DateAdd(DateInterval.Day, CType(-4, Integer), dataC)
            lblDix.Text = DateAdd(DateInterval.Day, CType(-3, Integer), dataC)
            lblDij.Text = DateAdd(DateInterval.Day, CType(-2, Integer), dataC)
            lblDiv.Text = DateAdd(DateInterval.Day, CType(-1, Integer), dataC)
        ElseIf LabelControl20.Text = “0” Then
            lblDill.Text = DateAdd(DateInterval.Day, CType(-6, Integer), dataC)
            lblDim.Text = DateAdd(DateInterval.Day, CType(-5, Integer), dataC)
            lblDix.Text = DateAdd(DateInterval.Day, CType(-4, Integer), dataC)
            lblDij.Text = DateAdd(DateInterval.Day, CType(-3, Integer), dataC)
            lblDiv.Text = DateAdd(DateInterval.Day, CType(-2, Integer), dataC)
        End If

    End Sub

From → Controles

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: