For r As Integer = 1912 To 1996 Step 12
zodiac = "Rat"
If uYear = r Then
MsgBox("Hi " & userName & ", your chinese zodiac is " & zodiac)
End If
Next
For o As Integer = 1913 To 1997 Step 12
zodiac = "Ox"
If uYear = o Then
MsgBox("Hi " & userName & ", your chinese zodiac is " & zodiac)
End If
Next
For t As Integer = 1914 To 1998 Step 12
zodiac = "Tiger"
If uYear = t Then
MsgBox("Hi " & userName & ", your chinese zodiac is " & zodiac)
End If
Next
The goal is to display different zodiac names based on the user’s birth year.
uYear is a variable that stores the user’s selected birth year that was taken from a combo box.
Ex:
if the year is 1912, 1924, 1936, 1948, 1960, 1972, 1984, 1996 then the output will be a Rat.
if the year is 1913, 1925, 1937, 1949, 1961, 1973, 1985. 1997 then the output will be an Ox.
Etc…
I haven’t tried anything because I can’t figure a out to a way to better write the code.
I thought of using nested loops but can’t figure out how to construct it.
Any assitance would be much appreciated.
Thank you.