Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyPress

Status
Not open for further replies.

davman2002

Programmer
Nov 4, 2002
75
0
0
US
I am trying to capture the Key that was pressed by the user. However I keep getting a mesage saying that it cannot convert a string type to a double. Here is my code. Any help is appreciated.

void __fastcall TfrmMain::MoveShip(TObject *Sender, char &Key)
{

if (Key == AnsiString("j"))
picShip->Left = picShip->Left + 5;
}
 
try

if (Key == 'j')
picShip->Left = picShip->Left + 5;

to much ansistring

tomcruz.net
 
I tried to use

if (Key == 'j')
picShip->Left = picShip->Left + 5;

But I get the same message as before Cannot convert string type to a double. really doesn't make any sense to me because if I use Key == 112 (Whcich I believe is the Ansi Equivalent it doesn't work either
 
Are you sure the problem isn't in
Code:
Left + 5
? Key is defined as a character and so is
Code:
'j'
. Is
Code:
picShip->Left
a string? James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Find out specifically which line the error is occuring on. It could be any of three places:
1. The if statement
2. The line below the if statement
3. Wherever you called this function from.
4. Some random place where you forgot a semicolon/curly brace.


Peter --
Find common answers using Google Groups:

 
what exactly is MoveShip

try
if (Key == VK_J) // just searching

tomcruz.net
 
Thanks for all the help,

I finally got it to work using

if (Key == 'j' || Key == 'J');

butthead MoveShip is a function that I created to move the pic around the screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top