Code Confusion
ok, after i got thelp with keypresses it is time to go one step further. i am ,making a very simple hangman game. the user will guess letters like you mormally do in hangman. what i want to be able to do is if he cant remember what he has guessed he can press a button. with that presss of the buttion all the letters/ keys that were captured would show up in a text box. but they would only show up when he pressed them.
i dont know if this is possible so any help would be great
Tayspen
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
great thank you. you guys are very helpful on this forum
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
ug im still consused though it always says lettersUsed is not defined. would any body mind giving sample code.
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
call me stupid but i cant get it it always gives me erros index of... does not exist
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
heres that part of it keep in mind im new :D
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
string keyData = "";
public Form1()
{
InitializeComponent();
string keyData = "";
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
bool result = false;
switch (keyData)
{
case(Keys.A):
if(lettersUsed.IndexOf("a") = -1) lettersUsed+= "a";
break;
case(Keys.Space):
MessageBox.Show("Letters used: " + lettersUsed);
break;
break;
}
return result;
}
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int hModule, int dwFlags);
}
}
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
not sure y that play sound dll import is in there lol
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
here it is closer i think
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form{
string lettersUsed = "";
public Form1()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref Message msg, Keys lettersUsed)
{
bool result = false;
switch (lettersUsed)
{
case(Keys.A):
if(lettersUsed.IndexOf("a") = -1) lettersUsed+= "a";
break;
case(Keys.Space):
MessageBox.Show("Letters used: " + lettersUsed);
break;
break;
}
return result;
}
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int hModule, int dwFlags);
}
}
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
so this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
string lettersUsed = "";
public Form1()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref Message msg, Keys pressedKey)
{
{
bool result = false;
switch (pressedKey)
{
case (Keys.A):
if (lettersUsed.IndexOf("a") = -1) lettersUsed += "a";
break;
case (Keys.Space):
MessageBox.Show("Letters used: " + lettersUsed);
break;
}
return result;
}
}
}
}
if that is right i still get errors.... :(
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
compiling
they are
cannot implicitly convert 'int' to 'bool'
and
the left hand side of an assigment must be a varible, propery, or idexer
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
do u no what the problem is?
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
thank you hank you thank you thank you. i really aprciate your help
thank you
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99