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 


nvm
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
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 1:45 pm    Post subject: nvm Reply with quote

ok so i decided to learn Visual C++, i made basic programs like show form , close , go to web page by press button etc.

here is what i want do to:

1.I Have textBox1 where i need to put number.
2.Click a Button then it will be divided by 3 then multiplicated by 2.
3.Result have to appear in textBox2.

here is what i did and when i click button , in textBox1 and textBox2 appear 0 -.-
Code:
   private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
          {
         int labelv;
         int liczba;
         int a = 3;
         int b = 2;
         int foo = System::Int32::Parse(textBox1->Text);
         textBox1->Text = Convert::ToString(liczba);
         labelv = (double)liczba / a * b;
         textBox2->Text = Convert::ToString(labelv);
          }

whats wrong? :S


Last edited by Wiw3K on Mon Dec 15, 2008 4:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 1:51 pm    Post subject: Reply with quote

maybe its this
change

int labelv;
int liczba;

for

double labelv;
double liczba;


?
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 1:54 pm    Post subject: Reply with quote

gogodr wrote:
maybe its this
change

int labelv;
int liczba;

for

double labelv;
double liczba;


?

still 0/0 at textBoxes Confused
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 1:59 pm    Post subject: Reply with quote

I dont get it much but should you add a

liczba = textBox1->Text

instead of

textBox1->Text = Convert::ToString(liczba);



---------------

its because

labelv & liczba
initial values is 0 and you are not changing that

0 / a * b
is 0


Last edited by gogodr on Mon Dec 15, 2008 2:04 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 2:04 pm    Post subject: Reply with quote

gogodr wrote:
I dont get it much but should you add a

liczba = textBox1->Text

instead of

textBox1->Text = Convert::ToString(liczba);

nah, not working, tried change everything alot times and search in google like 2h xd nothing Confused
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 2:06 pm    Post subject: Reply with quote

edited previous post, the problem is that you are not declaring anything to your variables
their inital value is 0 when declaring them and you are just saying there to change te textbox 1 text to o and then change the texbox 2 text to 0 / a * b wich is 0

try this one?

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX
TX = textBox1->Text
textBox2->Text == TX / 3 * 2;
}
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Dec 15, 2008 2:22 pm    Post subject: Reply with quote

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int labelv;
int liczba;
int a = 3;
int b = 2;
int foo = System::Int32::Parse(textBox1->Text);
textBox1->Text = Convert::ToString(liczba);
labelv = (double)liczba / a * b;
textBox2->Text = Convert::ToString(labelv);
}

I'm somewhat surprised this wouldn't throw a warning... unless you just ignored it.

you never init labelv, or liczba to anything. Maybe .NET will handle it for you? I guess that would make sense as to why you don't get anything in your textboxes.

You try and convert liczba to a string, but nothing is there to begin with. There's your first 0. liczba still doesn't equal anything, so your math is meaningless. 0 / (3 * 2) = 0. There's your second 0.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 2:41 pm    Post subject: Reply with quote

gogodr wrote:
edited previous post, the problem is that you are not declaring anything to your variables
their inital value is 0 when declaring them and you are just saying there to change te textbox 1 text to o and then change the texbox 2 text to 0 / a * b wich is 0

try this one?

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX
TX = textBox1->Text
textBox2->Text == TX / 3 * 2;
}

oh i see xd

you forgot few ;
now error appear about int -.-

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'
error C2446: '==' : no conversion from 'int' to 'System::String ^'
error C2040: '==' : 'System::String ^' differs in levels of indirection from 'int'

Confused
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 2:45 pm    Post subject: Reply with quote

Wiw3K wrote:
gogodr wrote:
edited previous post, the problem is that you are not declaring anything to your variables
their inital value is 0 when declaring them and you are just saying there to change te textbox 1 text to o and then change the texbox 2 text to 0 / a * b wich is 0

try this one?

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX
TX = textBox1->Text
textBox2->Text == TX / 3 * 2;
}

oh i see xd

you forgot few ;
now error appear :O?

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'
error C2446: '==' : no conversion from 'int' to 'System::String ^'
error C2040: '==' : 'System::String ^' differs in levels of indirection from 'int'

Confused


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text == Convert::ToString(TX / 3 * 2);
}


how about now ?
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 2:47 pm    Post subject: Reply with quote

gogodr wrote:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text == Convert::ToString(TX / 3 * 2);
}


how about now ?

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'

only one Confused
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 2:53 pm    Post subject: Reply with quote

Wiw3K wrote:
gogodr wrote:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text == Convert::ToString(TX / 3 * 2);
}


how about now ?

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'

only one Confused

oh , ok ok

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text = Convert::ToString(TX / 3 * 2);
}

this should do it
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 2:57 pm    Post subject: Reply with quote

gogodr wrote:
Wiw3K wrote:
gogodr wrote:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text == Convert::ToString(TX / 3 * 2);
}


how about now ?

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'

only one Confused

oh , ok ok

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text = Convert::ToString(TX / 3 * 2);
}

this should do it

you just deleted one =
textBox2->Text == Convert::ToString(TX / 3 * 2);
xd , the error is in line:
TX = textBox1->Text;
(error C2440: '=' : cannot convert from 'System::String ^' to 'int')
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Dec 15, 2008 3:01 pm    Post subject: Reply with quote

Wiw3K wrote:
gogodr wrote:
Wiw3K wrote:
gogodr wrote:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text == Convert::ToString(TX / 3 * 2);
}


how about now ?

Code:
error C2440: '=' : cannot convert from 'System::String ^' to 'int'

only one Confused

oh , ok ok

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = textBox1->Text;
textBox2->Text = Convert::ToString(TX / 3 * 2);
}

this should do it

you just deleted one =
textBox2->Text == Convert::ToString(TX / 3 * 2);
xd , the error is in line:
TX = textBox1->Text;
(error C2440: '=' : cannot convert from 'System::String ^' to 'int')


since I don't have the error lines location I though the error was the secondary =

ok ok

make sure you include stdlib.h to your project


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = atof(textBox1->Text);
textBox2->Text = Convert::ToString(TX / 3 * 2);
}
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Dec 15, 2008 3:02 pm    Post subject: Reply with quote

= is assignment.
== is comparison.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 15, 2008 3:10 pm    Post subject: Reply with quote

gogodr wrote:
since I don't have the error lines location I though the error was the secondary =

ok ok

make sure you include stdlib.h to your project


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int TX;
TX = atof(textBox1->Text);
textBox2->Text = Convert::ToString(TX / 3 * 2);
}

ok so error appear:
error C2664: 'atof' : cannot convert parameter 1 from 'System::String ^' to 'const char *'

but i know i need to #include "stdlib.h" , after i include , still appear.
I Think i doesnt have that file so i downloaded it and put in project folder
and still error popup Shocked whats wrong Shocked
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