|
Use int.TryParse instead of Convert::ToInt32. It's probably int::TryParse in C++/CLI
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
it's not working....
|
|
|
|
|
lavy2883 wrote: it's not working
What it? If you are getting exception it means that the string is not number
|
|
|
|
|
If I make the code like this
private: System::Void ContainerWidthtextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
W = Convert::ToInt32(ContainerWidthtextBox->Text);//, CultureInfo::CurrentCulture);
if(W <= 0)
{
MessageBox::Show("You must specify a Container Width greater than 0" , "Error", MessageBoxButtons::OK, MessageBoxIcon::Error, MessageBoxDefaultButton::Button1);
return
}
}
it's not working either..it put me the same error...but if I have in may interface another textbox let's say ContainerHeighttextBox and if I put the code like this.....
private: System::Void ContainerWidthtextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
//the code was first here
}
}
private: System::Void ContainerHeighttextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
//now I put it here
W = Convert::ToInt32(ContainerWidthtextBox->Text);//, CultureInfo::CurrentCulture);
if(W <= 0)
{
MessageBox::Show("You must specify a Container Width greater than 0" , "Error", MessageBoxButtons::OK, MessageBoxIcon::Error, MessageBoxDefaultButton::Button1);
return;
}
it's works but it's show me the messageBox after I introduce the value in the first textbox(it show me the messagebox at the seccond textbox not at the first where I need it )
lavi
|
|
|
|
|
You could also be having problems because you are using the TextChanged event. that means anytime you add/remove a character from the textbox it will fire this event which i don't think is what you want. I would rather use the Leave or Validating event. also i would do a bit more validating like checking for text length and use the Int32::TryParse like christian suggested.
if (ContainerWidthtextBox->TextLength > 0){
int w = 0;
if (Int32::TryParse(ContainerWidthtextBox->Text, w)){
if (w <= 0){
MessageBox::Show("You must specify a Container Width greater than 0" , "Error", MessageBoxButtons::OK, MessageBoxIcon::Error, MessageBoxDefaultButton::Button1);
return;
}
}
else
MessageBox::Show("you did not enter a valid number.");
}
-- modified at 12:28 Monday 28th May, 2007
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
thanks..,that was not realy my problem ...for example if for the "ContainerWidthtextBox" I have the value 230 from the interface and I want to put a condition for the "ContainerHeighttextBox" to not be less than 2*ConatinerWidthtextBox.... I managed to do this(to put the condition)...but it not let me to introduce all the numbers for the ContainerHeighttextBox because it give me ..... after the first number... let's say "2" MessageBox that the number introduced is not....whatever...please help me.
Y can solve this problem only if I put the condition in the textBox that it's after the ContainerHeighttextBox..let's say...depttextBox
lavy
|
|
|
|
|
You said 'it's not working', but you didn't do what I said....
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thanks...It help me a lot...sorry ...
|
|
|
|
|
hi all
if some one whit knowledege coud sacrify 2-3 minutes it woud save me a day time
a have a class X now i wana make a class Y wich woud derive all methodes, variables of X and has new ones
i wana ensure in X that certain methode are implemented in Y wich arent in X but declared
i wana overwrite methodes of X in Y
how do i write functions for operators that this works :
Myclass a=Myclass();
a++;
a=a*a;
...
..
i was try to use System::String inside a struct and was geting erros that i cant use a managed type in a struct blabla
i have solved this by using a class instead but woud by nice to know if there is a way around
similair problems seams to ocure if i try to use them as static
i woud like to have a static array in my class whit a pointer to all instances of this class this is important else way i have trubel
if some one coud give me a 10-20 line example it woud by great
just code no need for description
|
|
|
|
|
working half way
how can i get this out of class.h in to the class.cpp file :
virtual int Show(void){return 1;};
virtual int Show(void)override{....
something like :
virtual int Memory::Show(void)override{
wich isnt woking
|
|
|
|
|
You need to define operator* and operator+.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all
i want to know that when i return value from the function the value return to where
thank's for all
To Be Or Not To Be
(KARFER)
|
|
|
|
|
OSAMA SALLAM wrote: when i return value from the function the value return to where
the caller (really!)
-- modified at 13:42 Friday 25th May, 2007
I thought this question was familiar - see here[^]
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
This is the C++/CLI forum, I assume this question is about C++ in general. I recommend buying a very base level beginner book and working through it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Does this question for this forum or Sql ?
|
|
|
|
|
hi all
stuckt agein
hope i not highjack this hole topic
void Disp::Lock_Down(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){<br />
Lock->MouseMove += gcnew System::Windows::Forms::MouseEventHandler( this, &Disp::Lock_Drag );<br />
MousePosition=MainF->MousePosition;<br />
}<br />
void Disp::Lock_Up(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){<br />
>>>>>>>>>>>>>> not like this but how ??? :confused: <br />
Lock->MouseMove->Remove(this, &Disp::Lock_Drag);<br />
<<<<<<<<<<<<<<<br />
}
-- modified at 9:48 Friday 25th May, 2007
this works
void Disp::Lock_Down(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){<br />
t = gcnew System::Windows::Forms::MouseEventHandler( this, &Disp::Lock_Drag );<br />
Lock->MouseMove += t;<br />
MousePosition=MainF->MousePosition;<br />
}<br />
void Disp::Lock_Up(System::Object ^o, System::Windows::Forms::MouseEventArgs ^e){<br />
Lock->MouseMove -= t;<br />
}
BUT i realy not like "t"
is there a way to get it somehow else mayby out of Object ^o or MouseEventArgs ^e
or how ever whit out the need to store it by my self
|
|
|
|
|
i want a code of piano play with mouse in c++ coding
|
|
|
|
|
Wow
|
|
|
|
|
led mike wrote: Wow
World of Warcraft?
See Here[^]
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The above link is for the OP, BTW
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
1 - this is the C++/CLI forum. It's different to C++
2 - this is a place to ask for help with your code, not to request people give you code. I know of no place that allows you to ask for people to just write code for you, without offering to pay them for it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: this is a place to ask for help with your code, not to request people give you code
Well said.
|
|
|
|
|
hi friend
i start programming in c++ but i can't write a program with my knowledge i know the rules in programs but i don't know how to write a program please guide me to be a real programmer
Sincerely yours
|
|
|
|
|
First step, think about what you're doing. Like posting a question and putting 'question' in the header. Or asking a C++ question in the C++/CLI forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Google on "beginner c++ tutorial"
Kevin
|
|
|
|