|
|
|
Anonymous wrote:
dfgdfgdf
Are you learning ABCD......
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Yes, you ARE a moron. Next...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
very funny
V
|
|
|
|
|
My problem is that i need to do some addition, subtraction, and multiplication on a number and then display the result in a textbox or label or something like that so that it is displayed in the window. I have been trying to find how to convert from an int to a system::string (if it is even possible) but could not find anything. Am i going about this wrong just cannot figure out how to do it correctly. I am using microsoft visual c++ express edition 2005 beta 2.
I have tried searching the web for anything like this and could not find anything that would work. I have been working on this for over a week now and connot figure it out. I am new to programming so it is probably pretty simple but i cant find any help on this. Any help that anyone could offer would be greatly appreciated.
-Kyle
|
|
|
|
|
system::string means you're using managed C++, not normal C++ ? system::string has a Format method to do what you want. If you were using C++, then istringstream or *shudder* sprintf would convert int to string, or CString::Format ( from memory ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i am using managed c++. if you could include a sample code of how to use the System::String Format function it would help out greatly. i looked at it but it asked for a System::String and a System::Object what would i put for the each and where does the int variable go?
if i use a textbox named txt and an int variable named num, would it be:
txt->Text->Format(txt->Text, num);
is this right or am i way off??
thank you for the help.
-Kyle
|
|
|
|
|
The system::string is the format string, and the object is the object to format. You can pass in as many objects as you like, they are numbered from 0.
txt->Text = System::String::Format("{0}", num);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I tried that a few different ways some ways compiled but did not do what i wanted it to and the way that was posted gives me the following error:
error C2664: 'System::String ^System::String::Format(System::String ^,System::Object ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'<br />
1> No user-defined-conversion operator available, or<br />
1> No standard conversion exists from the boxed form of the arithmetic type to the target type
and would not compile.
i searched the web and found the stringbuilder class and was wondering if this would do what i wanted it to.
- Kyle
|
|
|
|
|
A string builder will do what you want, but it's overkill.
The basic problem is that MC++ is a crappy kludge, I'm glad I've never used it in depth. You need to manually box your integer for string::format to work. You do it like this:
int n = 2003;
Console::WriteLine(System::String::Format("{0}", __box(n)));
That is, this is an example of how to box your integer.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
if i try this it gives me the following error:
error C2227: left of '->ToString' must point to class/struct/union/generic type<br />
1> type is 'int'
- Kyle
|
|
|
|
|
|
Thank you Jose Lamas Rios. The num.ToString() worked.
I had been tring for quite some time to figure that out thank you very much.
- Kyle
|
|
|
|
|
|
i have sdk netmeeting3, i want to edit its. but i can't edit its with class wizart on VC++, can i?
|
|
|
|
|
You cannot edit the SDK, no. You can merely use the headers and lib files to link to it, so your code can call it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am learning Visual C++.net and have found that WinExec is no longer used/supported. I am trying to create a Windows Form employing a combo box. I want the user to select an item from the drop down list and have them run a program when the run button is clicked. How do I get The SelectedIndexChanged event to fire whenever the user selects a new program? Thanks for your inputs.
RRL
|
|
|
|
|
cupdoze wrote:
have them run a program when the run button is clicked
If that's the bit you're stuck on, the answer is ::ShellExecute.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
cupdoze wrote:
have found that WinExec is no longer used/supported.
In continuation With Mr. Graus,
you can refer this article too.....
http://www.codeproject.com/system/newbiespawn.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
can give some example of source code or project to write the server and client programming
|
|
|
|
|
I searched this site by typing 'client server' in the search dialog you can see just below the Code Project logo above, and found this[^].
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
After downloaded the server and client source code, I do not know how to build 2 project that one is for client and another is for server. can give some guide to build it? I really weak in computer programming and never touch Visual C++ before..
|
|
|
|
|
Are you being asked to do this by your boss or your teacher ? It's a really significant task if you've never used C++ before, if you can abandon it for something simpler, that would be sensible.
Why can't you build it ? What happens ? All you need to do is open the project and choose 'build', assuming you have the right version of VC++ ( I'm not sure which the project uses, actually )
Christian Graus - Microsoft MVP - C++
|
|
|
|