|
楼主 |
发表于 2013-12-26 08:14
|
显示全部楼层
本帖最后由 aoe1981 于 2013-12-26 08:15 编辑
Private Sub CommandButton1_Click()
Dim nf%, nfc%, tgs%, dzs%, tg(), dz(), rng As Range
tg = Array("甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸")
dz = Array("子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥")
If TextBox1.Text = "" Then TextBox2.Text = "": MsgBox "请输入要查询的年份!", , "友情提示": Exit Sub
If IsNumeric(TextBox1.Text) = False Then MsgBox "请输入数字年份,中间不能有空格!", , "友情提示": TextBox1.Text = "": TextBox2.Text = "": Exit Sub
If TextBox1.Text <> Int(TextBox1.Text) Then MsgBox "请输入整数年份!", , "友情提示": TextBox1.Text = "": TextBox2.Text = "": Exit Sub
If TextBox1.Text > 34750 Or TextBox1.Text < -30784 Then MsgBox "输入年份范围应当在[-30784,34750]之间!", , "友情提示": TextBox1.Text = "": TextBox2.Text = "": Exit Sub
If TextBox1.Text = 0 Then MsgBox "输入错误,没有公元0年!", , "友情提示": TextBox1.Text = "": TextBox2.Text = "": Exit Sub
If TextBox1.Text = 1984 Then TextBox2.Text = "甲子"
If TextBox1.Text > 1984 Then
nfc = TextBox1.Text - 1984 + 1
tgs = nfc Mod 10: If tgs = 0 Then tgs = 10
dzs = nfc Mod 12: If dzs = 0 Then dzs = 12
TextBox2.Text = tg(tgs - 1) & dz(dzs - 1)
End If
If TextBox1.Text < 1984 Then
nf = TextBox1.Text
If nf < 0 Then nf = nf + 1
nfc = 1984 - nf - 1
tgs = nfc Mod 10: tgs = 10 - tgs
dzs = nfc Mod 12: dzs = 12 - dzs
TextBox2.Text = tg(tgs - 1) & dz(dzs - 1)
End If
For Each rng In 参照表.Range("d6:d65")
If rng.Value = TextBox2.Text Then
rng.Resize(1, 3).Select
End If
Next
End Sub
这是修改后的代码,待会再传一个新附件。。。 |
|