如何从字符串中删除前导零
问题描述:
我必须从字符串中提取整数值.
它实际上是一个金额字段.
I have to extract the integer value from a string.
Its actually an amount field.
说字符串可以是 000000000000512
或 0000040000000
我只想要这个字符串中的整数值,即;512/40000000
请在 VB 脚本中对此提供帮助
Say string can be 000000000000512
or 0000040000000
I want only the integer value from this string i.e.; 512/ 40000000
Please help with this in VB scripting
答
CInt("000000000000512")
参见转换函数:http://msdn.microsoft.com/en-我们/图书馆/s2dy91zy.aspx
如果您希望有大量数字,请使用 Clng,正如评论中已经指出的那样:
Use Clng if you expect to have large numbers, as already pointed out in a comment:
Clng("000000004000512")
否则你会溢出,因为在 vbscript 中,variant 的子类型 int 是 16 位
otherwise you'll have an overflow, as variant's subtype int is 16 bit in vbscript