VBScript中 [英] vbscript

查看:71
本文介绍了VBScript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用instr函数来验证数字是否>或者<特定值?

Can the instr function be used to verify that a number is > or < a particular value?

例如:

如果  InStr 1 ,num1,num2,  1   >   0   然后

  &NBSP;   msgbox" num1大于num2'

If InStr(1, num1, num2, 1) > 0 Then
     msgbox "num1 is greater than num2'

结束如果




推荐答案

不。 InStr()函数仅查找某个起始位置后的部分字符串匹配。

No. The InStr() function looks only for a partial string match after a certain starting position.

由于VBScript只有Variant数据类型,因此需要确保将数字与数字进行比较。这里我们使用VBScript转换函数CDbl表示浮点值或CLng表示整数:

As VBScript has only the Variant data type, you need to ensure that you compare numbers with numbers. Here we use the VBScript conversion functions CDbl for floating point value or CLng for integer numbers:

Dim num1
Dim num2

If CDbl(num1) > CDbl(num2) Then
  MsgBox "num1 is greater than num2."
ElseIf CDbl(num1) < CDbl(num2) Then
  MsgBox "num1 is lesser than num2."
Else
  MsgBox "num1 equals num2."
End If


这篇关于VBScript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆