koossa
asked on
C# to VB.net
How would I do this in VB.net
strTemp.Format( _T("%02X%02X%02X"), arrData[ 5 ] & 0xFF, arrData[ 6 ] & 0xFF, arrData[ 7 ] & 0xFF);
ASKER
I have tried that, it does not work correctly
Check here. http://converter.telerik.com/
Some times you have to try some options to make the code without syntax error. This will help you somewhat( Reduce the typing of Vb.net)
Some times you have to try some options to make the code without syntax error. This will help you somewhat( Reduce the typing of Vb.net)
What is the need of this code... What you are trying to do? May i know the situation.
ASKER
When converting it, the vb.net does not understand the _T in the code.
I don't know what this code do, but there are 3 bytes and it convert it to a serial number with this code. I have that 3 bytes in vb.net and I also want to get the serial number.
I don't know what this code do, but there are 3 bytes and it convert it to a serial number with this code. I have that 3 bytes in vb.net and I also want to get the serial number.
A couple of points.
Your original code is NOT in C#, it is in fact C++, unmanaged code using an MFC specific macro - the _T thingy.
What the _T macro does is convert a string literal to UNICODE when that is defined in the project and convert it to ASCII when unicode is not a project setting.
As .net (VB and C#) all use unicode then the solution is simple. Just delete the _T( and the closing ) from the code.
Your original code is NOT in C#, it is in fact C++, unmanaged code using an MFC specific macro - the _T thingy.
What the _T macro does is convert a string literal to UNICODE when that is defined in the project and convert it to ASCII when unicode is not a project setting.
As .net (VB and C#) all use unicode then the solution is simple. Just delete the _T( and the closing ) from the code.
ASKER
Thank you Andy
Can you show me the vb.net code?
Can you show me the vb.net code?
>>When converting it, the vb.net does not understand the _T in the code.
As I said, just delete the _T and the braces () that went with it from your vb.net code.
eg
_T("%02X%02X%02X")
becomes
"%02X%02X%02X"
As I said, just delete the _T and the braces () that went with it from your vb.net code.
eg
_T("%02X%02X%02X")
becomes
"%02X%02X%02X"
ASKER
Ok, that is what I did, but it does not work, the strTemp is empty
strTemp.Format("%02X%02X%02X", arrData(5) & &HFF, arrData(6) & &HFF, arrData(7) & &HFF)
ASKER
arrData(5) = 112
arrData(6) = 55
arrData(7) = 97
Then it is suppose to return a 7 digit serial number
arrData(6) = 55
arrData(7) = 97
Then it is suppose to return a 7 digit serial number
Have you followed the advice of the other experts re the formatting ? (I assume that is what the links refer to - I'm more for C++, C# code)
ASKER
Hi Andy, as far as I can see the other posts is only links to C# to Vb.net converters, I don't see the formatting that you are talking about?
s = s.Format("{0:X2}{1:X2}{2:X 2}", 1, 2, 3)
this gives "010203"
this gives "010203"
ASKER
No, I don't think that is the same as the C++ code
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your patience!
http://www.developerfusion.com/tools/convert/csharp-to-vb/?batchId=5049da61-ac2f-4baa-9ae8-0feff54c6b01