AeroDawn
Legacy Member
Ik zit dus met een probleem.. ik wil een aantal members, waarvan ik de waarde in een eventhandler heb toegewezen, gebruiken in een andere functie. Maar gelijk waar in m'n klasse vind hij deze niet. Wat moet ik dan doen om deze members toch in de andere klasse te kunnen gebruiken? hier is de code ter verduidelijking (het gaat hier om een galg-spelletje)
ik geraak er maar niet uit...
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Galgje
{
public partial class WinGalgje : Form
{
//Members
readonly string[] WordList = new string[] // antwoorden
{ "Aardbei", "Appel", "Banaan", "Framboos" };
public int seed = 154345;
//Constructor
public WinGalgje()
{
InitializeComponent();
}
//Functions
void ClearWord()
{
TxtSolution.Text = "";
TxtLetter.Text = "";
PicResult.Image = Galgje.Properties.Resources.IMAGE1;
}//Clears the form - resetting
char[] SetWord(string[] _list, int _seed)
{
Random rand = new Random(_seed);
int RN = rand.Next(0, _list.Length - 1);
return _list[RN].ToCharArray();
}
char[] StartWord(char[] _word)
{
char[] output = new char[_word.Length];
for(int i = 0; i < _word.Length; i++)
{
output[i] = '-';
}
return output;
}
char[] FindLetterInString(char _letter, char[] _word)
{
char[] output = new char[_word.Length];
/* foreach (char _c in output)
{
_c = '-';
}*/
for (int i = 0; i < _word.Length; i++)
{
if (_letter == _word[i])
{
output[i] = _word[i];
}
else
{
output[i] = '-';
}
}
return output;
}
char[] UpdateText(char[] _old, char[] _update)
{
char[] output = new char[_old.Length];
if (_old.Length != _update.Length)
{
// the 2 char[] must be equal in length, otherwise
// no operation can be performed on the char[]s
MessageBox.Show("ERROR: _update.Length != _old.Length", "ERROR");
}
else
{
for (int i = 0; i < _old.Length; i++)
{
if (_update[i] != '-')
{
output[i] = _update[i];
}
else
{
output[i] = _old[i];
}
}
}
return output;
}
void TextBoxUpdate(char[] _input, TextBox _toUpdate)
{
foreach (char _s in _input)
{
_toUpdate.AppendText(_s.ToString());
_toUpdate.AppendText(" ");
}
}
//Event handlers
private void WinGalgje_Load(object sender, EventArgs e)
{
}
private void BtnQuit_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do you want to quit?", "Quit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
this.Close();
}
else
{
}
}
private void BtnRestart_Click(object sender, EventArgs e)
{
}
private void BtnOK_Click(object sender, EventArgs e)
{
}
}
}
ik geraak er maar niet uit...

.