Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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++

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];
		}


C++
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];
	}



From VB.NET

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


VB
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



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.
Posted
Comments
Sergey Alexandrovich Kryukov 12-Dec-13 9:38am    
Not clear. You think that showing C++ code can make it clear, but it you show code without declaration of variables. First, you need to explain what do you want to achieve. And you should not consider characters as integers of any type. .NET uses Unicode, which does not work this way...
—SA
Luiey Ichigo 12-Dec-13 22:24pm    
The code from C++ is : rsp[i+11] -= 0x30;
The code convert to VB is : rsp(i + 2) -= &H30

Now, can u help me to describe how to overcome this? I got error for "rsp(i + 2) -= &H30" which stated that: Operator '-' is not defined for types 'Char' and 'Integer'

On supplied C++ code there is more come for this calculation. I want to know the proper way to handle this kind of operation. Thank you

1 solution

Try:
VB
rsp(i + 11) -= ChrW(&H30)
Or better, declare a constant and use that:
VB
Private Const myOffsetValue As Char = CChar(&H30)
...
rsp(i + 11) -= myOffsetValue
 
Share this answer
 
Comments
Luiey Ichigo 12-Dec-13 22:21pm    
Hye Griff,

Still appear blue string noted that "Operator '-' is not defined for types 'Char' and 'Integer'"
OriginalGriff 13-Dec-13 3:37am    
Show me the lines of code that declare rsp and the exact code you added to do the add - copy and paste it from your app.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900