当前位置:编程学习 > VB >>

怎样在VB人品计算器的代码里添加特例?

下面是我的代码

Private Sub Command1_Click()
Dim n As Integer
Dim x, y As Integer
Dim addd As String
If Text1.Text = "" Then
    MsgBox "老大不要玩我名字都没有你想算什么!"
    ElseIf Text1 = "Nuit" Then
     Text2 = "你的人品已经过 100 人品计算器已经甘愿认输,3秒后人品计算器将易做图啊"
    Else
y = 0
For x = 1 To Len(Text1.Text)
y = y + AscW(Mid(Text1.Text, x, 1)) Mod 100
Next x
n = y Mod 100
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'如果n的值小于-20那么取n的值的非,否则n的值不变!
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If n < -20 Then n = Not n
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
         If (n = 0) Then
            addd = "你一定不是人吧?怎么一点人品都没有?!"
          ElseIf ((n > 0) And (n <= 5)) Then
            addd = "算了,跟你没什么人品好谈的..."
          ElseIf ((n > 5) And (n <= 10)) Then
            addd = "是我不好...不应该跟你谈人品问题的..."
          ElseIf ((n > 10) And (n <= 15)) Then
            addd = "杀过人没有?放过火没有?你应该无恶不做吧?"
          ElseIf ((n > 15) And (n <= 20)) Then
            addd = "你貌似应该三岁就偷看隔壁大妈洗澡的吧..."
          ElseIf ((n > 20) And (n <= 25)) Then
            addd = "你的人品之低下实在让人惊讶啊..."
          ElseIf ((n > 25) And (n <= 30)) Then
            addd = "你的人品太差了。你应该有干坏事的嗜好吧?"
          ElseIf ((n > 30) And (n <= 35)) Then
            addd = "你的人品真差!肯定经常做偷鸡摸狗的事..."
          ElseIf ((n > 35) And (n <= 40)) Then
            addd = "你拥有如此差的人品请经常祈求佛祖保佑你吧..."
          ElseIf ((n > 40) And (n <= 45)) Then
            addd = "老实交待..那些论坛上面经常出现的易做图照是不是你的杰作?"
          ElseIf ((n > 45) And (n <= 50)) Then
            addd = "你随地大小便之类的事没少干吧?"
          ElseIf ((n > 50) And (n <= 55)) Then
            addd = "你的人品太差了..稍不小心就会去干坏事了吧?"
          ElseIf ((n > 55) And (n <= 60)) Then
            addd = "你的人品很差了..要时刻克制住做坏事的冲动哦.."
          ElseIf ((n > 60) And (n <= 65)) Then
            addd = "你的人品比较差了..要好好的约束自己啊.."
          ElseIf ((n > 65) And (n <= 70)) Then
            addd = "你的人品勉勉强强..要自己好自为之.."
          ElseIf ((n > 70) And (n <= 75)) Then
            addd = "有你这样的人品算是不错了.."
          ElseIf ((n > 75) And (n <= 80)) Then
            addd = "你有较好的人品..继续保持.."
          ElseIf ((n > 80) And (n <= 85)) Then
            addd = "你的人品不错..应该一表人才吧?"
          ElseIf ((n > 85) And (n <= 90)) Then
            addd = "你的人品真好..做好事应该是你的爱好吧.."
          ElseIf ((n > 90) And (n <= 95)) Then
            addd = "你的人品太好了..你就是当代活雷锋啊..."
          ElseIf ((n > 95) And (n <= 99)) Then
            addd = "你是世人的榜样!"
          ElseIf (n > 100) And (a < 105) Then
            addd = "天啦!你不是人!你是神!!!"
          ElseIf (n > -∞) Then
            addd = "你的人品竟然负溢出了...我对你无语.."
          End If
         
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Text2.Text = "姓名:" & Text1.Text & vbCrLf & "人品得分:" & n & vbCrLf & "评价:" & addd & vbCrLf
    End If
 
End Sub

我的问题:

如果想输入某字符,然后输出的人品=0的话,我如何编写代码?添加在何处?

换句话说,假设这几个人的名字为张三,李四,王五,见他们的人品设为0,代码如何编写?

请讲的详细些。

最好有完整的代码

谢谢

答案:Private Sub Command1_Click()
Dim n As Integer
Dim x, y As Integer
Dim addd As String
If Text1.Text = "" Then
    MsgBox "老大不要玩我名字都没有你想算什么!"
    ElseIf Text1 = "Nuit" Then
     Text2 = "你的人品已经过 100 人品计算器已经甘愿认输,3秒后人品计算器将易做图啊"
    

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'增加的代码在此

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      ElseIf Text1 = "张三" Or Text1 = "李四" Or Text1 = "王五" Then 
     addd = "你一定不是人吧?怎么一点人品都没有?!"
     Text2.Text = "姓名:" & Text1.Text & vbCrLf & "人品得分:" & n & vbCrLf & "评价:" & addd & vbCrLf
    

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'增加的代码在上面

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Else
y = 0
For x = 1 To Len(Text1.Text)
y = y + AscW(Mid(Text1.Text, x, 1)) Mod 100
Next x
n = y Mod 100
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'如果n的值小于-20那么取n的值的非,否则n的值不变!
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If n < -20 Then n = Not n
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
         If (n = 0) Then
            addd = "你一定不是人吧?怎么一点人品都没有?!"
          ElseIf ((n > 0) And (n <= 5)) Then
            addd = "算了,跟你没什么人品好谈的..."
          ElseIf ((n > 5) And (n <= 10)) Then
            addd = "是我不好...不应该跟你谈人品问题的..."
          ElseIf ((n > 10) And (n <= 15)) Then
            addd = "杀过人没有?放过火没有?你应该无恶不做吧?"
          ElseIf ((n > 15) And (n <= 20)) Then
            addd = "你貌似应该三岁就偷看隔壁大妈洗澡的吧..."
          ElseIf ((n > 20) And (n <= 25)) Then
            addd = "你的人品之低下实在让人惊讶啊..."
          ElseIf ((n > 25) And (n <= 30)) Then
            addd = "你的人品太差了。你应该有干坏事的嗜好吧?"
          ElseIf ((n > 30) And (n <= 35)) Then
            addd = "你的人品真差!肯定经常做偷鸡摸狗的事..."
          ElseIf ((n > 35) And (n <= 40)) Then
            addd = "你拥有如此差的人品请经常祈求佛祖保佑你吧..."
          ElseIf ((n > 40) And (n <= 45)) Then
            addd = "老实交待..那些论坛上面经常出现的易做图照是不是你的杰作?"
          ElseIf ((n > 45) And (n <= 50)) Then
            addd = "你随地大小便之类的事没少干吧?"
          ElseIf ((n > 50) And (n <= 55)) Then
            addd = "你的人品太差了..稍不小心就会去干坏事了吧?"
          ElseIf ((n > 55) And (n <= 60)) Then
            addd = "你的人品很差了..要时刻克制住做坏事的冲动哦.."
          ElseIf ((n > 60) And (n <= 65)) Then
            addd = "你的人品比较差了..要好好的约束自己啊.."
          ElseIf ((n > 65) And (n <= 70)) Then
            addd = "你的人品勉勉强强..要自己好自为之.."
          ElseIf ((n > 70) And (n <= 75)) Then
            addd = "有你这样的人品算是不错了.."
          ElseIf ((n > 75) And (n <= 80)) Then
            addd = "你有较好的人品..继续保持.."
          ElseIf ((n > 80) And (n <= 85)) Then
            addd = "你的人品不错..应该一表人才吧?"
          ElseIf ((n > 85) And (n <= 90)) Then
            addd = "你的人品真好..做好事应该是你的爱好吧.."
          ElseIf ((n > 90) And (n <= 95)) Then
            addd = "你的人品太好了..你就是当代活雷锋啊..."
          ElseIf ((n > 95) And (n <= 99)) Then
            addd = "你是世人的榜样!"
          ElseIf (n > 100) And (a < 105) Then
            addd = "天啦!你不是人!你是神!!!"
          ElseIf (n > -∞) Then
            addd = "你的人品竟然负溢出了...我对你无语.."
          End If
         
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Text2.Text = "姓名:" & Text1.Text & vbCrLf & "人品得分:" & n & vbCrLf & "评价:" & addd & vbCrLf
    End If

End Sub

上一个:求高手发几段精彩的VB代码过来?
下一个:VB如何修改资源里的文字 追加100分

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,