Vbscript 将字符串转换为整数
问题是PrinterLabel是一个字符串,我想将其转换为Int并进行比较 PrinterLabel是一个字符串,也是一个数字“218”Vbscript 将字符串转换为整数,vbscript,Vbscript,问题是PrinterLabel是一个字符串,我想将其转换为Int并进行比较 PrinterLabel是一个字符串,也是一个数字“218” 有什么建议吗?您需要的功能是CInt ieCInt(打印机标签) 请参见MSDN上的(Visual Basic) 编辑:请注意,CInt及其亲属在VB.net和VBScript中的行为不同。例如,在VB.net中,CInt强制转换为32位整数,但在VBScript中,CInt强制转换为16位整数。注意潜在的溢出 我试图转换存储字符串的数组,但我得到了Typec
有什么建议吗?您需要的功能是
CInt
ieCInt(打印机标签)
请参见MSDN上的(Visual Basic)
编辑:请注意,CInt及其亲属在VB.net和VBScript中的行为不同。例如,在VB.net中,CInt强制转换为32位整数,但在VBScript中,CInt强制转换为16位整数。注意潜在的溢出 我试图转换存储字符串的数组,但我得到了
Typeconflict:“CInt”
@黑色数字字符串中必须有一些前导或尾随空格,请使用Trim
函数删除它们,然后使用CInt
将其转换为16位整数。
PrinterLabel = Printer + PrinterNumber
If Floors = 1 And (PrinterLabel) > 127 Then
Wscript.Echo "Invalid Printer11 Selection "
Wscript.Quit
End If
If Floors = 2 And PrinterLabel > 220 Then
Wscript.Echo "Invalid Printerss Selection "
Wscript.Quit
End If