Why is my form displaying wrongly?

vb6 Guatemala
  • 13 years ago

    Hi all!

    I have these Subs for calculating the Date and Weekday. The weekday works well(Mon-Sun).Now I have probs with the date..it starts from today to fill in. For example, instead of (mon-27th, tues-28th...), it shows(monday-29th, tues-30,wed-01 december).How can i make it to work correctly?

    Option Explicit
    Private Sub Form_Load()
    Call LoadDaysOfWeek
    Call LoadDate


    End Sub

    Private Sub LoadDaysOfWeek()
    ' Displays Days Of The Week
    Dim i As Integer
       
        For i = 0 To 5
            Load txtwkdayname(txtwkdayname.UBound + 1)
            txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8
            txtwkdayname(txtwkdayname.UBound).Visible = True
        Next i







        For i = 1 To 7
            txtwkdayname(i - 1) = WeekdayName(i, False, vbUseSystemDayOfWeek)
        Next i
    End Sub


    Private Sub LoadDate()
    ' Displays Date
    Dim i As Integer
       
        For i = 0 To 5
            Load txtDate(txtDate.UBound + 1)
            txtDate(txtDate.UBound).Top = (txtDate(i).Top + txtDate(i).Height) + 8
            txtDate(txtDate.UBound).Visible = True
        Next i







        For i = 1 To 7
        Date = Now()
            txtDate(i - 1).Text = DateAdd("d", i - 1, Date)
        Next i


  • 13 years ago

    Hi,

    You need to describe your problem a bit more clearly (aims, layout of form etc!!!), I can't really see what you are trying to do just from looking at your code.  You could do something like this

    The following code will get the dates/days of week/date suffix for the next week:

    Option Explicit

    Private Sub Form_Load()
    Dim currentdate As Date
    Dim aday As String
    currentdate = Date
    Dim a As Integer
    For a = 1 To 7
        currentdate = DateAdd("d", 1, currentdate)
        aday = DayOfWeek(Weekday(currentdate))
        Debug.Print aday & "-" & DateExt(Day(currentdate)) & " " & Month(currentdate)
    Next
    End Sub

    Private Function DayOfWeek(ByVal x As String)
    Select Case x
        Case Is = "1"
            x = "Sun"
        Case Is = "2"
            x = "Mon"
        Case Is = "3"
            x = "Tue"
        Case Is = "4"
            x = "Wed"
        Case Is = "5"
            x = "Thu"
        Case Is = "6"
            x = "Fri"
        Case Is = "7"
            x = "Sat"
    End Select
    DayOfWeek = x
    End Function

    Private Function DateExt(ByVal intDay As Integer) As String
            If IsNumeric(intDay) Then
                If (intDay < 11) Or (intDay > 13) Then
                Select Case Right(intDay, 1)
                   Case Is = 1
                         DateExt = intDay & "st"
                     Case Is = 2
                         DateExt = intDay & "nd"
                    Case Is = 3
                         DateExt = intDay & "rd"
                    Case Else
                        DateExt = intDay & "th"
                End Select
            Else
                DateExt = intDay & "th"
            End If
        End If
    End Function
























































  • 13 years ago

    Thanks sorry about not specifying in clear terms, without beating about the bush this is what i am trying to accomplish:

    I am building an outlook 2000 timesheet COM ADD IN, using vb6.

    You  have any ideas how i will go about it?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor