troubleshooting Question

convert vb.net to C#

Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada asked on
C#
4 Comments1 Solution483 ViewsLast Modified:
I need this correctly converted.
I appreciate it.
Dim chinese As String() = New String() {"Rat", _
    "Ox", _
    "Tiger", _
    "Hare", _
    "Dragon", _
    "Snake", _
    "Horse", _
    "Sheep", _
    "Monkey", _
    "Fowl", _
    "Dog", _
    "Pig"}
 
    Dim branches As String() = New String() {"Zi", _
    "Chou", _
    "Yin", _
    "Mao", _
    "Chen", _
    "Si", _
    "Wu", _
    "Wei", _
    "Shen", _
    "You", _
    "Xu", _
    "Hai"}
 
    Dim stems As String() = New String() {"Jia", _
    "Yi", _
    "Bing", _
    "Ding", _
    "Wu", _
    "Ji", _
    "Geng", _
    "Xin", _
    "Ren", _
    "Gui"}
 
    Dim chinesenewyear As Single() = New Single() {1.31, 2.19, 2.08, 1.29, 2.16, 2.04, 1.25, 2.13, 2.02, 1.22, _
                                       2.1, 1.3, 2.18, 2.06, 1.26, 2.14, 2.03, 1.23, 2.11, 2.01, _
                                       2.2, 2.08, 1.28, 2.16, 2.05, 1.25, 2.13, 2.02, 1.23, 2.1, _
                                       1.3, 2.17, 2.06, 1.26, 2.14, 2.04, 1.24, 2.11, 1.31, 2.19, _
                                       2.08, 1.27, 2.15, 2.05, 1.25, 2.13, 2.02, 1.22, 2.1, 1.29, _
                                       2.17, 2.06, 1.27, 2.14, 2.03, 1.24, 2.12, 1.31, 2.18, 2.08, _
                                       1.28, 2.15, 2.05, 1.25, 2.13, 2.02, 1.21, 2.09, 1.3, 2.17, _
                                       2.06, 1.27, 2.15, 2.03, 1.23, 2.11, 1.31, 2.18, 2.07, 1.28, _
                                       2.16, 2.05, 1.25, 2.13, 2.02, 2.2, 2.09, 1.29, 2.17, 2.06, _
                                       1.27, 2.15, 2.04, 1.23, 2.1, 1.31, 2.19, 2.07, 1.28, 2.16}
    Function getChinese(ByVal day As Integer, ByVal month As Integer, ByVal year As Integer)
        Dim newYear As Single
        Dim newMonth As Integer
        Dim newDay As Integer
        Dim chineseBranch = (year - 3) Mod 12
        Dim chineseStem = (year - 3) Mod 10
 
        If ((year > 1900) And (year < 1999)) Then
            newYear = chinesenewyear(year - 1899)
            newMonth = Math.Floor(newYear)
            newDay = Math.Round((newYear * 100) - (newMonth * 100))
 
            If ((month > newMonth) Or ((month = newMonth) And (day >= newDay))) Then
                ' this year
                chineseBranch = (year - 3) Mod 12
            Else
                ' last year
                chineseBranch = (year - 4) Mod 12
            End If
 
        Else
            chineseBranch = (year - 3) Mod 12
        End If
 
        If (chineseBranch = 0) Then
            chineseBranch = 12
        End If
        Return chinese(chineseBranch - 1)
    End Function
 
    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        TextBox1.Text = getChinese(DateTimePicker1.Value.Day, DateTimePicker1.Value.Month, DateTimePicker1.Value.Year)
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros