如何将数字与字符串值相加 [英] How to Add number with string values

查看:116
本文介绍了如何将数字与字符串值相加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从字符串中添加整数..

例如,

我想将一个数字与字符串值相加.
rdr("Code")的值为"AB"

最后,我想得到的结果是AB + 1,AB + 2这样的

例如:

昏暗的Cnt为整数= 1

Cnt = rdr("code")+ 1 ==>从字符串到int的错误转换

此处有任何问题...?

Hi,

How to add integer number from string..?

For Example,

I want to add one number with String values.
rdr("Code") value is "AB"

At end i want to get the result is AB+1,AB+2 like that

Ex:

Dim Cnt as integer = 1

Cnt = rdr("code") + 1 ==> Getting error conversion from string to int

Any problem here...?

推荐答案

如果要输出为"AB + 1","AB + 2",则需要将字符串附加为
If you want to output as "AB+1", "AB+2", then you need to append strings as
for (i=1;i<=5;i++)
{
  String op;
  op = rdr("code") + "+" + i.ToString();
}


您不能像现在那样用任何整数添加字符串"AB".


You cannot add string "AB" with any integer, as you are doing now.


这篇关于如何将数字与字符串值相加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆