Frage:
Wie kann man aus gegebenen Datum das
zugehörige Sternzeichen berechnen ?
Antwort:
Siehe folgende Routine
Quelle: http://www.ms-office-wissen.de/askdrmof/details.php?id=30
Public Function GetSternzeichen(dtDay As Date) As String
'*******************************************************
'Description: Berechnet das Sternzeichen eines Datums
'Parameters: dtDay
'Return: String
'-------------------------------------------------------
'Beispiel: MsgBox GetSternzeichen("01.01.2002")
'*******************************************************
Dim iDay As Integer
Dim iMonth As Integer
On Error GoTo HandleErr
If (Not IsDate(dtDay)) Then Exit Function
iDay = Day(dtDay)
iMonth = Month(dtDay)
If (iDay > 20 And iMonth = 1) Or _
(iDay < 20 And iMonth = 2) Then
GetSternzeichen = "Wassermann"
ElseIf (iDay > 19 And iMonth = 2) Or _
(iDay < 21 And iMonth = 3) Then
GetSternzeichen = "Fische"
ElseIf (iDay > 20 And iMonth = 3) Or _
(iDay < 21 And iMonth = 4) Then
GetSternzeichen = "Widder"
ElseIf (iDay > 20 And iMonth = 4) Or _
(iDay < 21 And iMonth = 5) Then
GetSternzeichen = "Stier"
ElseIf (iDay > 20 And iMonth = 5) Or _
(iDay < 22 And iMonth = 6) Then
GetSternzeichen = "Zwilling"
ElseIf (iDay > 21 And iMonth = 6) Or _
(iDay < 23 And iMonth = 7) Then
GetSternzeichen = "Krebs"
ElseIf (iDay > 22 And iMonth = 7) Or _
(iDay < 24 And iMonth = 8) Then
GetSternzeichen = "Löwe"
ElseIf (iDay > 23 And iMonth = 8) Or _
(iDay < 24 And iMonth = 9) Then
GetSternzeichen = "Jungfrau"
ElseIf (iDay > 23 And iMonth = 9) Or _
(iDay < 24 And iMonth = 10) Then
GetSternzeichen = "Waage"
ElseIf (iDay > 23 And iMonth = 10) Or _
(iDay < 23 And iMonth = 11) Then
GetSternzeichen = "Skorpion"
ElseIf (iDay > 22 And iMonth = 11) Or _
(iDay < 22 And iMonth = 12) Then
GetSternzeichen = "Schütze"
ElseIf (iDay > 21 And iMonth = 12) Or _
(iDay < 21 And iMonth = 1) Then
GetSternzeichen = "Steinbock"
End If
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Fehler " & Err.Number & ": " & _
Err.Description, vbCritical, "GetSternzeichen"
End Select
End Function
|