TC官方合作论坛

标题: 求助:str转int 转换失败。。 [打印本页]

作者: 4133789    时间: 2012-5-24 17:23
标题: 求助:str转int 转换失败。。
如题呢,转换一直失败,让我非常的无奈,但是自己也不知道是因为什么而失败了,求高手们能够指点一下,代码如下:

[attach]3414[/attach]

  1. int color
  2. string test
  3. test="9AA33E"
  4. color=convert.strtoint( test,0)
  5. help.messagebox(convert.inttostr(color))
复制代码


作者: 夏末    时间: 2012-5-24 17:32
04.color=convert.strtoint(test,0)

是转换 10进制的

你那好想是16进制的吧
作者: mahua1130    时间: 2012-5-24 17:46
楼上正解
作者: 4133789    时间: 2012-5-24 19:02
04.color=convert.strtoint(test,0)

是转换 10进制的

你那好想是16进制的吧
hohhohh 发表于 2012-5-24 17:32:05
那个,不能转16进制么?....
无语....表示我现在这一步非常需要呐.
能不能请前辈指点一下.

作者: 夏末    时间: 2012-5-24 19:20
color=convert.strtoint(test,1)

这个是把 16进制 转10进制 整型

功能描述 和 帮助文档 都有的啊

作者: aa4561233    时间: 2012-5-24 20:08
是转换 10进制的

你那好想是16进制的吧
作者: xuhekkll    时间: 2012-5-24 20:09
int color

  1. string test
  2. test="9AA33E"
  3. color=convert.strtoint( test,[color=Red]1[/color])
  4. help.messagebox(convert.inttostr(color))
复制代码

转换时,0为十进制转换,1为16进制转换。
作者: 4133789    时间: 2012-5-24 20:28
color=convert.strtoint(test,1)

这个是把 16进制 转10进制 整型

功能描述 和 帮助文档 都有的啊

hohhohh 发表于 2012-5-24 19:20:36
那个.不能直接转成16进制么?

表示有办法让整数10进制转16进制么?
非常需要这个功能呐.

作者: 夏末    时间: 2012-5-24 20:41
函数功能: 格式化字符串


%d  整数

%f  浮点数

%s  字符串

%c  单个字符

%x  十六进制

需要被格式化的数据: 可以是整型,浮点型,字符串,单个字符


  1. 整型 n=123456
  2. 字符型 m=字符串.格式化("%x",n)
复制代码



[attach]3415[/attach]
[attach]3415[/attach]


如果可用 给个最佳






欢迎光临 TC官方合作论坛 (http://bbs.52tc.co/) Powered by Discuz! X3.1