Excel VBScript:字符串问题
Excel VBScript: String issue
输入任意字符后,变量A中存储的值为“0”。任何人都可以在我出错的地方帮助我,因为如果我输入数字
它工作正常
菜鸟
Public Sub MyFirstProgram()
Dim A As String
A = Val(InputBox("Enter your name", "NAME"))
MsgBox "My name is " & A
End Sub
Val
函数将字符串转换为 Double
数字类型。
据推测,您输入的姓名无法转换为有效数字,因此结果为0
。
http://office.microsoft.com/en-us/excel-help/HV080557263.aspx
The Val function stops reading the string at the first character it can't recognize as part of a number.
因此,如果您执行类似 =Val("123steve")
的操作,它将 return 数字部分:123
,但如果您执行 =Val("Ebeneezer Scrooge")
,它将停止,根据上述说明 - - 由于没有个字符被转换为数值,它returns 0
.
输入任意字符后,变量A中存储的值为“0”。任何人都可以在我出错的地方帮助我,因为如果我输入数字
它工作正常菜鸟
Public Sub MyFirstProgram()
Dim A As String
A = Val(InputBox("Enter your name", "NAME"))
MsgBox "My name is " & A
End Sub
Val
函数将字符串转换为 Double
数字类型。
据推测,您输入的姓名无法转换为有效数字,因此结果为0
。
http://office.microsoft.com/en-us/excel-help/HV080557263.aspx
The Val function stops reading the string at the first character it can't recognize as part of a number.
因此,如果您执行类似 =Val("123steve")
的操作,它将 return 数字部分:123
,但如果您执行 =Val("Ebeneezer Scrooge")
,它将停止,根据上述说明 - - 由于没有个字符被转换为数值,它returns 0
.