如何从字符串中删除前导零 [英] how to remove leading zeroes from a string
本文介绍了如何从字符串中删除前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须从字符串中提取整数值.
它实际上是一个金额字段.
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
这篇关于如何从字符串中删除前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文