上次我们有活动。它正在将我同学的 python 代码转换为 vb ......这是我的最终代码,它正在运行。
Private Sub txtInput_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
curyear = Int(2013)
a = Int((curyear - txtInput.Text) Mod 12)
txtInput.Text = " "
If (a = 9) Or (a = -3) Then
txtOutput.Text = "Your zodiac sign is Snake"
ElseIf (a = 8) Or (a = -4) Then
txtOutput.Text = "Your zodiac sign is Dragon"
ElseIf (a = 7) Or (a = -5) Then
txtOutput.Text = "Your zodiac sign is Rabbit"
ElseIf (a = 6) Or (a = -6) Then
txtOutput.Text = "Your zodiac sign is Tiger"
ElseIf (a = 5) Or (a = -7) Then
txtOutput.Text = "Your zodiac sign is Ox"
ElseIf (a = 4) Or (a = -8) Then
txtOutput.Text = "Your zodiac sign is Rat"
ElseIf (a = 3) Or (a = -9) Then
txtOutput.Text = "Your zodiac sign is Pig"
ElseIf (a = 2) Or (a = -10) Then
txtOutput.Text = "Your zodiac sign is Dog"
ElseIf (a = 1) Or (a = -11) Then
txtOutput.Text = "Your zodiac sign is Rooster"
ElseIf (a = 0) Or (a = -2) Then
txtOutput.Text = "Your zodiac sign is Monkey"
ElseIf (a = 11) Or (a = -1) Then
txtOutput.Text = "Your zodiac sign is Sheep"
ElseIf (a = 12) Or (a = 0) Then
txtOutput.Text = "Your zodiac sign is Horse"
End If
End If
End Sub
我们的教授告诉我有关 ascii 13/enter 的其他用途……我不太了解他。您认为我的代码有什么问题?它正在运行,但他说我的代码是错误的。