-
November 25th, 2012, 08:05 AM
#1
Transformation Error. I can not output a variable in TextBox Read more: http://forum
Hi, all. Please, Help me. Its very important for me. I try to output a variable, type string, in TextBox. I tried everything that I could. But always the mistake. And i show you a file Form1.h in which i have got a problem.
That's my project
Code:
private: System::Void button20_Click(System::Object^ sender, System::EventArgs^ e)
{
adding();
textBox1->Text = b.ToString();
}
Read more: http://forum.codecall.net/topic/73059-transformation-error-i-can-not-output-a-variable-in-textbox/#ixzz2DEsO7nNe
Code:
void adding()
{
b = (textBox1.Text).ToString();
// b = (richTextBox1->Text).ToString();
/*CLargeNumber oLN1 = CLargeNumber(1000000);
oLN1 -= CLargeNumber(2000000);
cout << "Answer " << cout << oLN1.ToString() << endl;
system("pause");*/
//Testing the LargeNumber class
CLargeNumber oLN1(a);
CLargeNumber oLN2(B);
b=(oLN1+oLN2).ToString();
}
Read more: http://forum.codecall.net/topic/73059-transformation-error-i-can-not-output-a-variable-in-textbox/#ixzz2DEsUjXhv
-
November 25th, 2012, 02:23 PM
#2
Re: Transformation Error. I can not output a variable in TextBox Read more: http://f
Dear Pahanuch,
unfortunately your code has nothig to do with VC++ not is it a native C++ code.
What you showed us looks like managed C++ code that is discussed in a corresponding Managed C++ and C++/CLI forum.
Victor Nijegorodov
-
November 25th, 2012, 04:55 PM
#3
Re: Transformation Error. I can not output a variable in TextBox
Thank U. I decided this problem
Code:
std::string str;
const char* temp = (const char*)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox1->Text)).ToPointer();
str = temp;
System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr((void*)temp));
textBox2->Text = gcnew String(str.c_str() );
-
November 25th, 2012, 05:06 PM
#4
Re: Transformation Error. I can not output a variable in TextBox
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
November 26th, 2012, 04:22 AM
#5
Re: Transformation Error. I can not output a variable in TextBox Read more: http://f
[ redirected ]
I don't know what exactly you're trying to do, but this looks seriously bad. Can you explain in details what do you want to store in the textbox?
-
November 27th, 2012, 07:08 PM
#6
Re: Transformation Error. I can not output a variable in TextBox Read more: http://f
Eri523, it was just an example. I don't need to equate
Code:
textBox2->Text = textBox1->Text;
First. I need to convert a variable, type string. And output it in a richTextBox1.
Second. And I need to get value from TextBox1 and TextBox2 to variables, type string.
Last edited by Pahanuch; November 27th, 2012 at 08:15 PM.
-
November 27th, 2012, 07:14 PM
#7
Re: Transformation Error. I can not output a variable in TextBox Read more: http://f
cilu , I want to do calculator for very large numbers. textBox1 - for first number. textBox2 - for second number. And richTextBox1 for output answer.
-
November 27th, 2012, 08:27 PM
#8
Re: Transformation Error. I can not output a variable in TextBox Read more: http://f
Originally Posted by Pahanuch
First. I need to convert a variable, type string. And output it in a richTextBox1.
Second. And I need to get value from TextBox1 and TextBox2 to variables, type string.
You don't actually need to do any conversion between text boxes and variables of type System::String. The text box' Text property is of the very same type System::String so you can freely do assignments back and forth between the two.
Originally Posted by Pahanuch
[...] I want to do calculator for very large numbers. textBox1 - for first number. textBox2 - for second number. And richTextBox1 for output answer.
For this you actually would need to do some conversion. Unless you're going to write your own bignum class (what I somewhat doubt), you'd probably use the BigInteger class. It features the Parse() and TryParse() methods supported by most numeric types to convert from a string and ToString() to convert to a string. (Actually, ToString() is supported by literally all .NET types, but for many types it doesnt return a really useful result.)
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
November 27th, 2012, 09:55 PM
#9
Re: Transformation Error. I can not output a variable in TextBox
Eri523 Thank U very mush. For my program I used this class.
I was trying Parse(), TryParse() and ToString(). The compiler gave out a mistake(
-
November 28th, 2012, 05:11 AM
#10
Re: Transformation Error. I can not output a variable in TextBox
Originally Posted by Pahanuch
This class is native C++, and although it can be done in C++/CLI, managed and native code shouldn't be mixed without a really good reason to do so. If done by people who don't know exactly what they're doing, it may lead to weird code like that in post #3.
I was trying Parse(), TryParse() and ToString(). The compiler gave out a mistake(
Getting plain error messages when trying to use the correct language/library features is not a good reason to use questionable (in this context) techniques instead. The error messages are there to tell you there's something wrong with your code, so you have the opportunity to fix it. Once you have fixed it, you have a solid .NET program, and when something goes wrong with that at runtime, the exceptions thrown by .NET code usually carry some information that are quite helpful in diagnosing the problem. OTOH, interop, when done wrong, may not cause compiler or linker errors, but later lead to a malfunctioning program at runtime. And this sort of problem often is pretty hard to find...
So I suggest you post the .NET-based code you can't get to compile, preferably along with the error messages you get, and we try to fix it together.
Last edited by Eri523; November 28th, 2012 at 05:13 AM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|