C ++转换为VB流程 [英] C++ translate to VB flow

查看:92
本文介绍了C ++转换为VB流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好编码员,



我在这里面临一个问题。我不是C ++人。我做VB.Net。我有一个.h和.cpp文件。有些代码是成功翻译的,但代码中有一件我无法理解的东西。有人可以体验C和VB.NEt看到这个。以下是我的代码:



来自C ++



Hi coders,

I'm facing a problem here. I'm not C++ person. I do VB.Net. I got a .h and .cpp file. Some of the code is successfully translate but there is 1 thing from the code that I can't understand. Can someone who experience the C and VB.NEt to see this. Below are my code:

From C++

for(i=0;i<3;i++)	rsp[i+11] -= 0x30;
		check_size = rsp[11];
		for(i=0;i<2;i++)		{	
			check_size <<= 4;
			check_size += rsp[i+12];
		}







for(i=0;i<3;i++)  rsp[i+2] -= 0x30;// MICR data length : rsp[2],[3],[4] 
	len = rsp[2];
	for(i=0;i<2;i++)									
	{	
		len <<= 4;
		len += rsp[i+3];
	}







来自VB.NET






From VB.NET

For i = 0 To 2 '
                rsp(i + 2) -= &H30
            Next i







For i = 0 To 2 ' MICR data length : rsp[2],[3],[4]
                    rsp(i + 11) -= &H30
                Next i
                check_size = rsp(11)
                For i = 0 To 1
                    check_size <<= 4
                    check_size += rsp(i + 12)
                Next i







如果您发现我的问题不明确,请道歉。 C ++代码与我的问题无关。但VB.NET代码是我现在面临的问题。它在rsp(i + 2) - =& H30,rsp(i + 11) - =& H30上出现错误蓝色字符串,并且与rsp事物和 - =或+的计算有关=。看起来操作符 - 没有定义为整数到字符,字符到整数为+。在C ++上,它声明为char和unsigned char。但我也尝试将rsp作为stringbuilder和byte()。但仍然是错误。如何说清楚?对不起,当我遇到麻烦时,我的英语不好。




Apologize if you find my question is not clear. The C++ code is nothing to do with my question. But the VB.NET code is my problem that I'm facing now. It error blue string on "rsp(i + 2) -= &H30", "rsp(i + 11) -= &H30" and something to do with the "rsp" thing and the calculation for -= or +=. It appear Operator "-" is not defined for type "Integer" to "Char" and "Char" to "Integer" for "+". On C++, it declare as char and unsigned char. But I also try rsp as stringbuilder and byte(). But still error. How to make it clear? Sorry, my english is not good when I'm in trouble.

推荐答案

尝试:

Try:
rsp(i + 11) -= ChrW(&H30)

或者更好,声明一个常量并使用:

Or better, declare a constant and use that:

Private Const myOffsetValue As Char = CChar(&H30)
...
rsp(i + 11) -= myOffsetValue


这篇关于C ++转换为VB流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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