13. november 2001 - 12:05Der er
16 kommentarer og 1 løsning
Calendar skal returnere DayOfWeek (f.eks. onsdag)
Hey,
Jeg har et lille problem men en kalender i VB. Jeg skal have den valgte dag ud. Dvs hvis der vælges 13. november 2001 så skal jeg kunne skrive i en msgbox Onsdag.
Private Function MaxDayInMonth(nMonth As Long, Optional nYear As Long = 0) As Long Select Case nMonth Case 9, 4, 6, 11 MaxDayInMonth = 30 Case 2 If (nYear Mod 4) = 0 Then If nYear Mod 100 = 0 Then If nYear Mod 400 = 0 Then MaxDayInMonth = 29 Else MaxDayInMonth = 28 End If Else MaxDayInMonth = 29 End If Else MaxDayInMonth = 28 End If Case Else MaxDayInMonth = 31 End Select End Function
Private Sub Combo1_Click() Dim i As Long Combo2.Clear For i = 1 To MaxDayInMonth(Val(Combo1.ListIndex + 1), Val(Text2)) Combo2.AddItem i Next i Combo2.ListIndex = 0 End Sub
Private Sub Combo2_Click() Text1 = Format(WeekDay(DateSerial(Val(Text2), Val(Combo1.ListIndex + 1), Val(Combo2.ListIndex + 1))), \"dddd\") \'Dato End Sub
Private Sub Form_Load() Dim i As Long
Text1.Text = \"\" Text2.Text = \"2001\"
For i = 1 To 12 Combo1.AddItem (i) & \" - \" & Format(\"1-\" & i & \"-0\", \"MMMM\") Next i Combo1.ListIndex = 0 End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.