相关疑难解决方法(0)

VB6 Can IsNumeric会出错吗?

是否可以使用IsNumeric()测试字符串并返回true,但是当您使用CInt()将相同的字符串转换为整数并将其分配给integer类型的变量时,它会给出类型不匹配错误?

我问因为我得到了一个类型不匹配错误,所以我在尝试强制转换之前使用IsNumeric()检查字符串是否为数字,但我仍然得到错误.

我正用这个撕掉我的头发.

这是有问题的代码. iGlobalMaxAlternatives = CInt(strMaxAlternatives)是发生错误的地方.

Dim strMaxAlternatives As String
Dim iGlobalMaxAlternatives As Integer
iGlobalMaxAlternatives = 0
bSurchargeIncInFare = True

strMaxAlternatives = ReadStringKeyFromRegistry("Software\TL\Connection Strings\" & sConn & "\HH", "MaxAlt")

If IsNumeric(strMaxAlternatives) And strMaxAlternatives <> "" Then
    iGlobalMaxAlternatives = CInt(strMaxAlternatives)
End If
Run Code Online (Sandbox Code Playgroud)

vb6 casting isnumeric

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

casting ×1

isnumeric ×1

vb6 ×1