Chr(Int(Val("&H" & Mid(ftype, 1, 2)))) in c# ?
- thank you for any help converting this to a c# string ! -hazz
Chr(Int(Val("&H" & Mid(ftype, 1, 2))))
using c# ?
Réponses
- It's hard to replace VB's 'Val' function, so you might want to just use it directly until you get a good equivalent for your needs:
(char)((int)Math.Floor(Microsoft.VisualBasic.Conversion.Val("&H" + ftype.Substring(0, 2))));
Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)- Marqué comme réponsehazz mercredi 4 novembre 2009 17:44
Heslacher,
It is terrible converting VB6 to C# but special for you in a VB Net forum
:-)
char s = (char) Convert.ToInt32(ftype.Substring(0,2), 16);
But for VB Net not so different
Dim s = ChrW(Convert.ToInt32(ftype.Substring(0, 2), 16))
Success
Cor- Marqué comme réponsehazz mercredi 4 novembre 2009 18:15
Toutes les réponses
{
string s = Strings.Chr(Conversion.Int(Conversion.Val("&H" + Strings.Mid(ftype, 1, 2))));
}
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/- Proposé comme réponseBalaji Baskar mercredi 4 novembre 2009 15:43
You would better ask this in a C# forum, giving the string and what character you want.
Helslacher has build in my idea a real new program language
Success
Cor- Hi Cor,
yes you are right, but it was on accident. Changed it. The rest of the code has come from the online converter.
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
{
string s = Strings.Chr(Conversion.Int(Conversion.Val("&H" + Strings.Midftype, 1, 2))));
}
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
there is a little problem with the brackets, i have corrected this:
string s = Strings.Chr(Conversion.Int(Conversion.Val("&H" + Strings.Midftype, 1, 2)));
Balaji Baskar [Please mark the post as answer if it answers your question]Thank you Heslacher !
That assignment statement as below generated the compiler errors;
1. For the Conversion methods - Argument '1': cannot convert from 'double' to 'int'
2. For the whole statement - The best overloaded method match for 'Microsoft.VisualBasic.Strings.Chr(int)' has some invalid argumentspublic object buildpacket(ref int d, int s, string ftype, string pdu) { string strF = Strings.Chr(Conversion.Int(Conversion.Val("&H" + Strings.Mid(ftype, 1, 2)))); }
Thank you Heslacher !
That assignment statement as below generated the compiler errors;
1. For the Conversion methods - Argument '1': cannot convert from 'double' to 'int'
2. For the whole statement - The best overloaded method match for 'Microsoft.VisualBasic.Strings.Chr(int)' has some invalid arguments
hazz, there is some bracketing issues, put this line in your code:string s = Strings.Chr(Conversion.Int(Conversion.Val("&H" + Strings.Midftype, 1, 2)));
Balaji Baskar [Please mark the post as answer if it answers your question]- Proposé comme réponseBalaji Baskar mercredi 4 novembre 2009 17:03
http://tinyurl.com/yldzpmg
hopefully illustrates the problem more clearly.
The line of code in the vb.net app at the top of the image compiles/runs correctly.
The C# conversion below it does not.- It's hard to replace VB's 'Val' function, so you might want to just use it directly until you get a good equivalent for your needs:
(char)((int)Math.Floor(Microsoft.VisualBasic.Conversion.Val("&H" + ftype.Substring(0, 2))));
Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)- Marqué comme réponsehazz mercredi 4 novembre 2009 17:44
- Thank you David. No compile problem. I'll test for functional equivalence.
With much appreciation.
Greg Heslacher,
It is terrible converting VB6 to C# but special for you in a VB Net forum
:-)
char s = (char) Convert.ToInt32(ftype.Substring(0,2), 16);
But for VB Net not so different
Dim s = ChrW(Convert.ToInt32(ftype.Substring(0, 2), 16))
Success
Cor- Marqué comme réponsehazz mercredi 4 novembre 2009 18:15
- Hi David,
I find the one from me nicer, although you did the same like me.
Not creating a string from it
:-)
Cor - Thank you Cor !
I'll test this out as well for functional equivalency as well ...
Much much appreciated.
Greg

