Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VC++] Int to String for Textbox
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Tue Nov 25, 2008 10:52 pm    Post subject: [VC++] Int to String for Textbox Reply with quote

I need to convert a int to a string, so I can have a textbox display it. I have already found out how to convert the textbox's text to an int, i just need to do it in reverse.

Is there something like this:

Code:
this->textBox1->Text = int1.ToString;


Because it isn't working for me. Very Happy
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Tue Nov 25, 2008 11:26 pm    Post subject: Reply with quote

This is in C#, but i'm sure it will give you the basic idea as for IntToStr
http://msdn.microsoft.com/en-us/library/aa664785.aspx

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Nov 25, 2008 11:29 pm    Post subject: Reply with quote

ugh god don't use Manged C++, it's no longer supported.

Use C# instead, and look at the Convert class.

Convert->ToInt32(TextBox1->Text);


Last edited by hcavolsdsadgadsg on Tue Nov 25, 2008 11:32 pm; edited 1 time in total
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Tue Nov 25, 2008 11:32 pm    Post subject: Reply with quote

No longer supported? ?Tahw yas
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Tue Nov 25, 2008 11:33 pm    Post subject: Reply with quote

sprintf(message,"%d",value);

converts int value to string message

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Wed Nov 26, 2008 10:21 am    Post subject: Reply with quote

try itoa

int to asci o0

wtf ppl read more documentation!

or for the opposite
try atoi

ascii to int o0

....grr...
Back to top
View user's profile Send private message MSN Messenger
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Wed Nov 26, 2008 10:35 am    Post subject: Reply with quote

Bizarro wrote:
sprintf(message,"%d",value);

converts int value to string message


First, using "%d" will convert it into a value not a string.

Second, it would only use the int as an ascii of the char.
Back to top
View user's profile Send private message MSN Messenger
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Wed Nov 26, 2008 11:57 am    Post subject: Reply with quote

Code:
int int1 = 20;
char char1[100];
_itoa (int1, char1, 10);
this->textBox1->Text = Convert::ToString(char1);


That works... And so does this....

Code:
int int1 = 20;
this->textBox1->Text = Convert::ToString(int1);


Ty. And screw C#, that will never be as good as C++.
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Wed Nov 26, 2008 12:10 pm    Post subject: Reply with quote

Zerith wrote:
Bizarro wrote:
sprintf(message,"%d",value);

converts int value to string message


First, using "%d" will convert it into a value not a string.

Second, it would only use the int as an ascii of the char.

You're wrong. Bizarro is right, that code will convert the value of 'value' to a string and put that string into 'message'.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Nov 26, 2008 12:43 pm    Post subject: Reply with quote

Chaosis13 wrote:
Code:
int int1 = 20;
char char1[100];
_itoa (int1, char1, 10);
this->textBox1->Text = Convert::ToString(char1);


That works... And so does this....

Code:
int int1 = 20;
this->textBox1->Text = Convert::ToString(int1);


Ty. And screw C#, that will never be as good as C++.


Except you're not using C++, you're using the managed version. Yes, it runs off the .NET framework, and no, there is no support for managed C++ any more. Microsoft doesn't support the product.

It's outdated, shitty, and completely outclassed by C# in any way you slice it.
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Wed Nov 26, 2008 12:47 pm    Post subject: Reply with quote

I don't care, I normally don't use VC++, I prefer Dev-C++. I just wanted to spend less time programming the interface. And I will never learn C#.
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Wed Nov 26, 2008 1:03 pm    Post subject: Reply with quote

tombana wrote:
Zerith wrote:
Bizarro wrote:
sprintf(message,"%d",value);

converts int value to string message


First, using "%d" will convert it into a value not a string.

Second, it would only use the int as an ascii of the char.

You're wrong. Bizarro is right, that code will convert the value of 'value' to a string and put that string into 'message'.



Definition of "%d" by MSDN:

MSDN wrote:

d Signed decimal integer.


I suppose MSDN is wrong then?
Back to top
View user's profile Send private message MSN Messenger
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Wed Nov 26, 2008 1:18 pm    Post subject: Reply with quote

Zerith wrote:
tombana wrote:
Zerith wrote:
Bizarro wrote:
sprintf(message,"%d",value);

converts int value to string message


First, using "%d" will convert it into a value not a string.

Second, it would only use the int as an ascii of the char.

You're wrong. Bizarro is right, that code will convert the value of 'value' to a string and put that string into 'message'.



Definition of "%d" by MSDN:

MSDN wrote:

d Signed decimal integer.


I suppose MSDN is wrong then?


Definition of "sprintf" by MSDN:

MSDN wrote:

sprintf Write formatted data to a string.


I suppose MSDN is wrong then?²

_________________
Gone
Back to top
View user's profile Send private message
ElJEffro
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Apr 2007
Posts: 1881
Location: La Tierra

PostPosted: Wed Nov 26, 2008 1:29 pm    Post subject: Reply with quote

yeah, and
sprintf(string1, "%X", int1); will format it in hexadecimal number style too if you need that (capital X for format like 0xF33BA3, lower case x for format like 0xf33ba3). You can pad it left as well with it as well "%04X" or %0<number of characters long you want the number to be>< whatever format you are using >

int int1 = 40;
char intAsString[4];
sprintf(intAsString, "%d", int1); //will get you a string "40"
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Wed Nov 26, 2008 1:38 pm    Post subject: Reply with quote

ElJEffro wrote:
yeah, and
sprintf(string1, "%X", int1); will format it in hexadecimal number style too if you need that (capital X for format like 0xF33BA3, lower case x for format like 0xf33ba3). You can pad it left as well with it as well "%04X" or %0<number of characters long you want the number to be>< whatever format you are using >

int int1 = 40;
char intAsString[4];
sprintf(intAsString, "%d", int1); //will get you a string "40"

I was just saing to Zerith that %d is for decimal numbers but "sprintf" copies it to an string.

_________________
Gone
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites