vbs if else语句
蒜泥白肉的做法vbs if else语句
VBScript是一种微软开发的脚本语言,可以用于Windows操作系统的自动化任务和脚本编写。其中的if else语句是一种常用的条件控制语句,用来根据特定条件执行不同的代码块。下面将列举10个使用VBScript的if else语句的例子,每个例子都能满足上述要求。
1. 判断一个数的正负性:
```vbscript
Dim num
num = InputBox("请输入一个数字")
If num > 0 Then
    MsgBox "这是一个正数"
ElseIf num < 0 Then
    MsgBox "这是一个负数"
Else
    MsgBox "这是零"
End If
```
2. 判断一个数是否为偶数:
```vbscript
Dim num
num = InputBox("请输入一个数字")
If num Mod 2 = 0 Then
    MsgBox "这是一个偶数"
Else
    MsgBox "这是一个奇数"银行利息2022年最新存款利率表
End If
```
3. 根据用户输入的年份判断是否为闰年:
```vbscript
Dim year
year = InputBox("请输入一个年份")
If (year Mod 4 = 0 And year Mod 100 <> 0) Or year Mod 400 = 0 Then
    MsgBox "这是一个闰年"
Else
    MsgBox "这不是一个闰年"
End If
```
4. 根据用户输入的成绩判断等级:
```vbscript
Dim score
score = InputBox("请输入一个成绩")
If score >= 90 Then
    MsgBox "优秀"
ElseIf score >= 80 Then
    MsgBox "良好"
ElseIf score >= 70 Then
    MsgBox "中等"
ElseIf score >= 60 Then
    MsgBox "及格"
Else
    MsgBox "不及格"
End If
```
5. 判断用户输入的字符串是不是回文串:
```vbscript
Dim str, i
str = InputBox("请输入一个字符串")
For i = 1 To Len(str) / 2
    If Mid(str, i, 1) <> Mid(str, Len(str) - i + 1, 1) Then
        MsgBox "这不是一个回文串"
        Exit For
    End If
Next
If i > Len(str) / 2 Then
    MsgBox "这是一个回文串"
End If
```
6. 根据用户输入的月份判断季节:
```vbscript
Dim month
month = InputBox("请输入一个月份")
If month >= 3 And month <= 5 Then
    MsgBox "这是春季"
ElseIf month >= 6 And month <= 8 Then
    MsgBox "这是夏季"
ElseIf month >= 9 And month <= 11 Then
    MsgBox "这是秋季"
Else
    MsgBox "这是冬季"
End If
```
7. 根据用户输入的年龄判断是否成年:
收到承兑汇票分录
```vbscript
Dim age
age = InputBox("请输入一个年龄")
If age >= 18 Then
    MsgBox "已成年"
Else
    MsgBox "未成年"饮水机制冷原理
End If圣诞祝福语大全简短
```
8. 根据用户输入的两个数判断大小关系:
```vbscript
Dim num1, num2
num1 = InputBox("请输入第一个数字")
num2 = InputBox("请输入第二个数字")
If num1 > num2 Then
    MsgBox "第一个数字大于第二个数字"
意味深长的句子

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。