I need help on how to transfer the individual characters of the answer(which is a string stored on a text file) and display it on idividual labels. This is a very incomplete program and quite long so any help on making it better would really be appreciated
Also if you need more info please do ask... I'll be happy to help... Hope you can help me out on this one.
Oh, by the way this is the form thingy...
Here's the code:
#pragma once
namespace HangarooMain {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Text;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
protected:
private: System::Windows::Forms::Label^ lblQuestion;
private: System::Windows::Forms::Button^ btnS;
private: System::Windows::Forms::Button^ btnA;
private: System::Windows::Forms::Button^ btnB;
private: System::Windows::Forms::Button^ btnC;
private: System::Windows::Forms::Button^ btnD;
private: System::Windows::Forms::Button^ btnE;
private: System::Windows::Forms::Button^ btnF;
private: System::Windows::Forms::Button^ btnG;
private: System::Windows::Forms::Button^ btnH;
private: System::Windows::Forms::Button^ btnI;
private: System::Windows::Forms::Button^ btnY;
private: System::Windows::Forms::Button^ btnR;
private: System::Windows::Forms::Button^ btnQ;
private: System::Windows::Forms::Button^ btnP;
private: System::Windows::Forms::Button^ btnO;
private: System::Windows::Forms::Button^ btnN;
private: System::Windows::Forms::Button^ btnM;
private: System::Windows::Forms::Button^ btnL;
private: System::Windows::Forms::Button^ btnK;
private: System::Windows::Forms::Button^ btnJ;
private: System::Windows::Forms::Button^ btnX;
private: System::Windows::Forms::Button^ btnW;
private: System::Windows::Forms::Button^ btnV;
private: System::Windows::Forms::Button^ btnU;
private: System::Windows::Forms::Button^ btnT;
private: System::Windows::Forms::Button^ btnZ;
private: System::Windows::Forms::Label^ lblX1;
private: System::Windows::Forms::Label^ lblX2;
private: System::Windows::Forms::Label^ lblX3;
private: System::Windows::Forms::Label^ lblX4;
private: System::Windows::Forms::Label^ lblX5;
private: System::Windows::Forms::Label^ lblCL;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ mnuFile;
private: System::Windows::Forms::ToolStripMenuItem^ mnuNewGame;
private: System::Windows::Forms::ToolStripMenuItem^ mnuExit;
private: System::Windows::Forms::ToolStripMenuItem^ mnuAbout;
private: System::Windows::Forms::ToolStripMenuItem^ mnuAboutTheProgrammer;
private: System::Windows::Forms::ToolStripMenuItem^ mnuAboutTheGame;
private: System::Windows::Forms::TextBox^ txtQuestion;
private: System::Windows::Forms::TextBox^ txtAnswer;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
int randomNumber,x,IndexNumber;
int arraySize;
String^ line;
String^ msg1;
String^ msg;
String^ Question;
String^ Answer;
String^ separator;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
String^ A;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->lblQuestion = (gcnew System::Windows::Forms::Label());
this->btnS = (gcnew System::Windows::Forms::Button());
this->btnA = (gcnew System::Windows::Forms::Button());
this->btnB = (gcnew System::Windows::Forms::Button());
this->btnC = (gcnew System::Windows::Forms::Button());
this->btnD = (gcnew System::Windows::Forms::Button());
this->btnE = (gcnew System::Windows::Forms::Button());
this->btnF = (gcnew System::Windows::Forms::Button());
this->btnG = (gcnew System::Windows::Forms::Button());
this->btnH = (gcnew System::Windows::Forms::Button());
this->btnI = (gcnew System::Windows::Forms::Button());
this->btnY = (gcnew System::Windows::Forms::Button());
this->btnR = (gcnew System::Windows::Forms::Button());
this->btnQ = (gcnew System::Windows::Forms::Button());
this->btnP = (gcnew System::Windows::Forms::Button());
this->btnO = (gcnew System::Windows::Forms::Button());
this->btnN = (gcnew System::Windows::Forms::Button());
this->btnM = (gcnew System::Windows::Forms::Button());
this->btnL = (gcnew System::Windows::Forms::Button());
this->btnK = (gcnew System::Windows::Forms::Button());
this->btnJ = (gcnew System::Windows::Forms::Button());
this->btnX = (gcnew System::Windows::Forms::Button());
this->btnW = (gcnew System::Windows::Forms::Button());
this->btnV = (gcnew System::Windows::Forms::Button());
this->btnU = (gcnew System::Windows::Forms::Button());
this->btnT = (gcnew System::Windows::Forms::Button());
this->btnZ = (gcnew System::Windows::Forms::Button());
this->lblX1 = (gcnew System::Windows::Forms::Label());
this->lblX2 = (gcnew System::Windows::Forms::Label());
this->lblX3 = (gcnew System::Windows::Forms::Label());
this->lblX4 = (gcnew System::Windows::Forms::Label());
this->lblX5 = (gcnew System::Windows::Forms::Label());
this->lblCL = (gcnew System::Windows::Forms::Label());
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mnuNewGame = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mnuExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mnuAbout = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mnuAboutTheProgrammer = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mnuAboutTheGame = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->txtQuestion = (gcnew System::Windows::Forms::TextBox());
this->txtAnswer = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// lblQuestion
//
this->lblQuestion->AutoSize = true;
this->lblQuestion->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblQuestion->Location = System::Drawing::Point(19, 43);
this->lblQuestion->Name = L"lblQuestion";
this->lblQuestion->Size = System::Drawing::Size(121, 23);
this->lblQuestion->TabIndex = 12;
this->lblQuestion->Text = L"QUESTION:";
//
// btnS
//
this->btnS->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnS->ForeColor = System::Drawing::Color::Red;
this->btnS->Location = System::Drawing::Point(111, 214);
this->btnS->Name = L"btnS";
this->btnS->Size = System::Drawing::Size(46, 42);
this->btnS->TabIndex = 13;
this->btnS->Text = L"S";
this->btnS->UseVisualStyleBackColor = true;
this->btnS->Click += gcnew System::EventHandler(this, &Form1::btnS_Click);
//
// btnA
//
this->btnA->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnA->ForeColor = System::Drawing::Color::Red;
this->btnA->Location = System::Drawing::Point(59, 214);
this->btnA->Name = L"btnA";
this->btnA->Size = System::Drawing::Size(46, 42);
this->btnA->TabIndex = 14;
this->btnA->Text = L"A";
this->btnA->UseVisualStyleBackColor = true;
this->btnA->Click += gcnew System::EventHandler(this, &Form1::btnA_Click);
//
// btnB
//
this->btnB->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnB->ForeColor = System::Drawing::Color::Red;
this->btnB->Location = System::Drawing::Point(277, 262);
this->btnB->Name = L"btnB";
this->btnB->Size = System::Drawing::Size(46, 42);
this->btnB->TabIndex = 15;
this->btnB->Text = L"B";
this->btnB->UseVisualStyleBackColor = true;
this->btnB->Click += gcnew System::EventHandler(this, &Form1::btnB_Click);
//
// btnC
//
this->btnC->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnC->ForeColor = System::Drawing::Color::Red;
this->btnC->Location = System::Drawing::Point(173, 262);
this->btnC->Name = L"btnC";
this->btnC->Size = System::Drawing::Size(46, 42);
this->btnC->TabIndex = 16;
this->btnC->Text = L"C";
this->btnC->UseVisualStyleBackColor = true;
this->btnC->Click += gcnew System::EventHandler(this, &Form1::btnC_Click);
//
// btnD
//
this->btnD->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnD->ForeColor = System::Drawing::Color::Red;
this->btnD->Location = System::Drawing::Point(163, 214);
this->btnD->Name = L"btnD";
this->btnD->Size = System::Drawing::Size(46, 42);
this->btnD->TabIndex = 17;
this->btnD->Text = L"D";
this->btnD->UseVisualStyleBackColor = true;
this->btnD->Click += gcnew System::EventHandler(this, &Form1::btnD_Click);
//
// btnE
//
this->btnE->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnE->ForeColor = System::Drawing::Color::Red;
this->btnE->Location = System::Drawing::Point(154, 166);
this->btnE->Name = L"btnE";
this->btnE->Size = System::Drawing::Size(46, 42);
this->btnE->TabIndex = 18;
this->btnE->Text = L"E";
this->btnE->UseVisualStyleBackColor = true;
this->btnE->Click += gcnew System::EventHandler(this, &Form1::btnE_Click);
//
// btnF
//
this->btnF->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnF->ForeColor = System::Drawing::Color::Red;
this->btnF->Location = System::Drawing::Point(215, 214);
this->btnF->Name = L"btnF";
this->btnF->Size = System::Drawing::Size(46, 42);
this->btnF->TabIndex = 19;
this->btnF->Text = L"F";
this->btnF->UseVisualStyleBackColor = true;
this->btnF->Click += gcnew System::EventHandler(this, &Form1::btnF_Click);
//
// btnG
//
this->btnG->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnG->ForeColor = System::Drawing::Color::Red;
this->btnG->Location = System::Drawing::Point(267, 214);
this->btnG->Name = L"btnG";
this->btnG->Size = System::Drawing::Size(46, 42);
this->btnG->TabIndex = 20;
this->btnG->Text = L"G";
this->btnG->UseVisualStyleBackColor = true;
this->btnG->Click += gcnew System::EventHandler(this, &Form1::btnG_Click);
//
// btnH
//
this->btnH->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnH->ForeColor = System::Drawing::Color::Red;
this->btnH->Location = System::Drawing::Point(319, 214);
this->btnH->Name = L"btnH";
this->btnH->Size = System::Drawing::Size(46, 42);
this->btnH->TabIndex = 21;
this->btnH->Text = L"H";
this->btnH->UseVisualStyleBackColor = true;
this->btnH->Click += gcnew System::EventHandler(this, &Form1::btnH_Click);
//
// btnI
//
this->btnI->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnI->ForeColor = System::Drawing::Color::Red;
this->btnI->Location = System::Drawing::Point(414, 166);
this->btnI->Name = L"btnI";
this->btnI->Size = System::Drawing::Size(46, 42);
this->btnI->TabIndex = 22;
this->btnI->Text = L"I";
this->btnI->UseVisualStyleBackColor = true;
this->btnI->Click += gcnew System::EventHandler(this, &Form1::btnI_Click);
//
// btnY
//
this->btnY->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnY->ForeColor = System::Drawing::Color::Red;
this->btnY->Location = System::Drawing::Point(310, 166);
this->btnY->Name = L"btnY";
this->btnY->Size = System::Drawing::Size(46, 42);
this->btnY->TabIndex = 23;
this->btnY->Text = L"Y";
this->btnY->UseVisualStyleBackColor = true;
this->btnY->Click += gcnew System::EventHandler(this, &Form1::btnY_Click);
//
// btnR
//
this->btnR->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnR->ForeColor = System::Drawing::Color::Red;
this->btnR->Location = System::Drawing::Point(206, 166);
this->btnR->Name = L"btnR";
this->btnR->Size = System::Drawing::Size(46, 42);
this->btnR->TabIndex = 33;
this->btnR->Text = L"R";
this->btnR->UseVisualStyleBackColor = true;
this->btnR->Click += gcnew System::EventHandler(this, &Form1::btnR_Click);
//
// btnQ
//
this->btnQ->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnQ->ForeColor = System::Drawing::Color::Red;
this->btnQ->Location = System::Drawing::Point(50, 166);
this->btnQ->Name = L"btnQ";
this->btnQ->Size = System::Drawing::Size(46, 42);
this->btnQ->TabIndex = 32;
this->btnQ->Text = L"Q";
this->btnQ->UseVisualStyleBackColor = true;
this->btnQ->Click += gcnew System::EventHandler(this, &Form1::btnQ_Click);
//
// btnP
//
this->btnP->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnP->ForeColor = System::Drawing::Color::Red;
this->btnP->Location = System::Drawing::Point(518, 166);
this->btnP->Name = L"btnP";
this->btnP->Size = System::Drawing::Size(46, 42);
this->btnP->TabIndex = 31;
this->btnP->Text = L"P";
this->btnP->UseVisualStyleBackColor = true;
this->btnP->Click += gcnew System::EventHandler(this, &Form1::btnP_Click);
//
// btnO
//
this->btnO->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnO->ForeColor = System::Drawing::Color::Red;
this->btnO->Location = System::Drawing::Point(466, 166);
this->btnO->Name = L"btnO";
this->btnO->Size = System::Drawing::Size(46, 42);
this->btnO->TabIndex = 30;
this->btnO->Text = L"O";
this->btnO->UseVisualStyleBackColor = true;
this->btnO->Click += gcnew System::EventHandler(this, &Form1::btnO_Click);
//
// btnN
//
this->btnN->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnN->ForeColor = System::Drawing::Color::Red;
this->btnN->Location = System::Drawing::Point(329, 262);
this->btnN->Name = L"btnN";
this->btnN->Size = System::Drawing::Size(46, 42);
this->btnN->TabIndex = 29;
this->btnN->Text = L"N";
this->btnN->UseVisualStyleBackColor = true;
this->btnN->Click += gcnew System::EventHandler(this, &Form1::btnN_Click);
//
// btnM
//
this->btnM->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnM->ForeColor = System::Drawing::Color::Red;
this->btnM->Location = System::Drawing::Point(381, 262);
this->btnM->Name = L"btnM";
this->btnM->Size = System::Drawing::Size(46, 42);
this->btnM->TabIndex = 28;
this->btnM->Text = L"M";
this->btnM->UseVisualStyleBackColor = true;
this->btnM->Click += gcnew System::EventHandler(this, &Form1::btnM_Click);
//
// btnL
//
this->btnL->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnL->ForeColor = System::Drawing::Color::Red;
this->btnL->Location = System::Drawing::Point(475, 214);
this->btnL->Name = L"btnL";
this->btnL->Size = System::Drawing::Size(46, 42);
this->btnL->TabIndex = 27;
this->btnL->Text = L"L";
this->btnL->UseVisualStyleBackColor = true;
this->btnL->Click += gcnew System::EventHandler(this, &Form1::btnL_Click);
//
// btnK
//
this->btnK->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnK->ForeColor = System::Drawing::Color::Red;
this->btnK->Location = System::Drawing::Point(423, 214);
this->btnK->Name = L"btnK";
this->btnK->Size = System::Drawing::Size(46, 42);
this->btnK->TabIndex = 26;
this->btnK->Text = L"K";
this->btnK->UseVisualStyleBackColor = true;
//
// btnJ
//
this->btnJ->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnJ->ForeColor = System::Drawing::Color::Red;
this->btnJ->Location = System::Drawing::Point(371, 214);
this->btnJ->Name = L"btnJ";
this->btnJ->Size = System::Drawing::Size(46, 42);
this->btnJ->TabIndex = 25;
this->btnJ->Text = L"J";
this->btnJ->UseVisualStyleBackColor = true;
this->btnJ->Click += gcnew System::EventHandler(this, &Form1::btnJ_Click);
//
// btnX
//
this->btnX->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnX->ForeColor = System::Drawing::Color::Red;
this->btnX->Location = System::Drawing::Point(121, 262);
this->btnX->Name = L"btnX";
this->btnX->Size = System::Drawing::Size(46, 42);
this->btnX->TabIndex = 42;
this->btnX->Text = L"X";
this->btnX->UseVisualStyleBackColor = true;
this->btnX->Click += gcnew System::EventHandler(this, &Form1::btnX_Click);
//
// btnW
//
this->btnW->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnW->ForeColor = System::Drawing::Color::Red;
this->btnW->Location = System::Drawing::Point(102, 166);
this->btnW->Name = L"btnW";
this->btnW->Size = System::Drawing::Size(46, 42);
this->btnW->TabIndex = 41;
this->btnW->Text = L"W";
this->btnW->UseVisualStyleBackColor = true;
this->btnW->Click += gcnew System::EventHandler(this, &Form1::btnW_Click);
//
// btnV
//
this->btnV->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnV->ForeColor = System::Drawing::Color::Red;
this->btnV->Location = System::Drawing::Point(225, 262);
this->btnV->Name = L"btnV";
this->btnV->Size = System::Drawing::Size(46, 42);
this->btnV->TabIndex = 40;
this->btnV->Text = L"V";
this->btnV->UseVisualStyleBackColor = true;
this->btnV->Click += gcnew System::EventHandler(this, &Form1::btnV_Click);
//
// btnU
//
this->btnU->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnU->ForeColor = System::Drawing::Color::Red;
this->btnU->Location = System::Drawing::Point(362, 166);
this->btnU->Name = L"btnU";
this->btnU->Size = System::Drawing::Size(46, 42);
this->btnU->TabIndex = 39;
this->btnU->Text = L"U";
this->btnU->UseVisualStyleBackColor = true;
this->btnU->Click += gcnew System::EventHandler(this, &Form1::btnU_Click);
//
// btnT
//
this->btnT->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnT->ForeColor = System::Drawing::Color::Red;
this->btnT->Location = System::Drawing::Point(258, 166);
this->btnT->Name = L"btnT";
this->btnT->Size = System::Drawing::Size(46, 42);
this->btnT->TabIndex = 38;
this->btnT->Text = L"T";
this->btnT->UseVisualStyleBackColor = true;
this->btnT->Click += gcnew System::EventHandler(this, &Form1::btnT_Click);
//
// btnZ
//
this->btnZ->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnZ->ForeColor = System::Drawing::Color::Red;
this->btnZ->Location = System::Drawing::Point(68, 262);
this->btnZ->Name = L"btnZ";
this->btnZ->Size = System::Drawing::Size(46, 42);
this->btnZ->TabIndex = 43;
this->btnZ->Text = L"Z";
this->btnZ->UseVisualStyleBackColor = true;
this->btnZ->Click += gcnew System::EventHandler(this, &Form1::btnZ_Click);
//
// lblX1
//
this->lblX1->BackColor = System::Drawing::Color::Silver;
this->lblX1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->lblX1->Location = System::Drawing::Point(441, 43);
this->lblX1->Name = L"lblX1";
this->lblX1->Size = System::Drawing::Size(25, 23);
this->lblX1->TabIndex = 45;
this->lblX1->TextChanged += gcnew System::EventHandler(this, &Form1::label2_TextChanged);
//
// lblX2
//
this->lblX2->BackColor = System::Drawing::Color::Silver;
this->lblX2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->lblX2->Location = System::Drawing::Point(472, 43);
this->lblX2->Name = L"lblX2";
this->lblX2->Size = System::Drawing::Size(25, 23);
this->lblX2->TabIndex = 46;
//
// lblX3
//
this->lblX3->BackColor = System::Drawing::Color::Silver;
this->lblX3->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->lblX3->Location = System::Drawing::Point(503, 43);
this->lblX3->Name = L"lblX3";
this->lblX3->Size = System::Drawing::Size(25, 23);
this->lblX3->TabIndex = 47;
//
// lblX4
//
this->lblX4->BackColor = System::Drawing::Color::Silver;
this->lblX4->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->lblX4->Location = System::Drawing::Point(534, 43);
this->lblX4->Name = L"lblX4";
this->lblX4->Size = System::Drawing::Size(25, 23);
this->lblX4->TabIndex = 48;
//
// lblX5
//
this->lblX5->BackColor = System::Drawing::Color::Silver;
this->lblX5->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->lblX5->Location = System::Drawing::Point(565, 43);
this->lblX5->Name = L"lblX5";
this->lblX5->Size = System::Drawing::Size(25, 23);
this->lblX5->TabIndex = 49;
//
// lblCL
//
this->lblCL->AutoSize = true;
this->lblCL->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblCL->Location = System::Drawing::Point(272, 43);
this->lblCL->Name = L"lblCL";
this->lblCL->Size = System::Drawing::Size(162, 23);
this->lblCL->TabIndex = 50;
this->lblCL->Text = L"CHANCES LEFT:";
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuFile, this->mnuAbout});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(614, 24);
this->menuStrip1->TabIndex = 51;
this->menuStrip1->Text = L"menuStrip1";
//
// mnuFile
//
this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuNewGame,
this->mnuExit});
this->mnuFile->Name = L"mnuFile";
this->mnuFile->Size = System::Drawing::Size(35, 20);
this->mnuFile->Text = L"&File";
//
// mnuNewGame
//
this->mnuNewGame->Name = L"mnuNewGame";
this->mnuNewGame->Size = System::Drawing::Size(136, 22);
this->mnuNewGame->Text = L"&New Game";
//
// mnuExit
//
this->mnuExit->Name = L"mnuExit";
this->mnuExit->Size = System::Drawing::Size(136, 22);
this->mnuExit->Text = L"E&xit";
this->mnuExit->Click += gcnew System::EventHandler(this, &Form1::mnuExit_Click);
//
// mnuAbout
//
this->mnuAbout->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuAboutTheProgrammer,
this->mnuAboutTheGame});
this->mnuAbout->Name = L"mnuAbout";
this->mnuAbout->Size = System::Drawing::Size(48, 20);
this->mnuAbout->Text = L"&About";
//
// mnuAboutTheProgrammer
//
this->mnuAboutTheProgrammer->Name = L"mnuAboutTheProgrammer";
this->mnuAboutTheProgrammer->Size = System::Drawing::Size(194, 22);
this->mnuAboutTheProgrammer->Text = L"About the &Programmer";
//
// mnuAboutTheGame
//
this->mnuAboutTheGame->Name = L"mnuAboutTheGame";
this->mnuAboutTheGame->Size = System::Drawing::Size(194, 22);
this->mnuAboutTheGame->Text = L"About the &Game";
//
// txtQuestion
//
this->txtQuestion->BackColor = System::Drawing::Color::Chartreuse;
this->txtQuestion->Enabled = false;
this->txtQuestion->Font = (gcnew System::Drawing::Font(L"Tahoma", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->txtQuestion->Location = System::Drawing::Point(23, 69);
this->txtQuestion->Multiline = true;
this->txtQuestion->Name = L"txtQuestion";
this->txtQuestion->Size = System::Drawing::Size(567, 40);
this->txtQuestion->TabIndex = 52;
this->txtQuestion->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// txtAnswer
//
this->txtAnswer->Enabled = false;
this->txtAnswer->Location = System::Drawing::Point(162, 115);
this->txtAnswer->Name = L"txtAnswer";
this->txtAnswer->PasswordChar = '+';
this->txtAnswer->Size = System::Drawing::Size(290, 20);
this->txtAnswer->TabIndex = 53;
this->txtAnswer->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->ForeColor = System::Drawing::Color::Red;
this->button1->Location = System::Drawing::Point(50, 166);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(46, 42);
this->button1->TabIndex = 32;
this->button1->Text = L"Q";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::btnQ_Click);
//
// button2
//
this->button2->Font = (gcnew System::Drawing::Font(L"Tahoma", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button2->ForeColor = System::Drawing::Color::Red;
this->button2->Location = System::Drawing::Point(102, 166);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(46, 42);
this->button2->TabIndex = 41;
this->button2->Text = L"W";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::btnW_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->ClientSize = System::Drawing::Size(614, 385);
this->Controls->Add(this->txtAnswer);
this->Controls->Add(this->txtQuestion);
this->Controls->Add(this->lblCL);
this->Controls->Add(this->lblX5);
this->Controls->Add(this->lblX4);
this->Controls->Add(this->lblX3);
this->Controls->Add(this->lblX2);
this->Controls->Add(this->lblX1);
this->Controls->Add(this->btnZ);
this->Controls->Add(this->btnX);
this->Controls->Add(this->button2);
this->Controls->Add(this->btnW);
this->Controls->Add(this->btnV);
this->Controls->Add(this->btnU);
this->Controls->Add(this->btnT);
this->Controls->Add(this->btnR);
this->Controls->Add(this->button1);
this->Controls->Add(this->btnQ);
this->Controls->Add(this->btnP);
this->Controls->Add(this->btnO);
this->Controls->Add(this->btnN);
this->Controls->Add(this->btnM);
this->Controls->Add(this->btnL);
this->Controls->Add(this->btnK);
this->Controls->Add(this->btnJ);
this->Controls->Add(this->btnY);
this->Controls->Add(this->btnI);
this->Controls->Add(this->btnH);
this->Controls->Add(this->btnG);
this->Controls->Add(this->btnF);
this->Controls->Add(this->btnE);
this->Controls->Add(this->btnD);
this->Controls->Add(this->btnC);
this->Controls->Add(this->btnB);
this->Controls->Add(this->btnA);
this->Controls->Add(this->btnS);
this->Controls->Add(this->lblQuestion);
this->Controls->Add(this->menuStrip1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"HANGAROO 1.0";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
//frmGameOpen ^Game=gcnew frmGameOpen();
//Game->Show();
randomNumber=0; A="A";
x=0;
IndexNumber=0;
arraySize=50;
separator="=";
array<System::String^>^ tempArray = gcnew array<String^>(arraySize);
String^ path = "c:\\test.txt";
StreamReader^ sr = gcnew StreamReader( path );
try
{
try
{
// Read the lines from the file until the end of
// the file is reached.
while ( sr->Peek() >= 0 )
{
msg= sr->ReadLine();
tempArray[x]=msg;
x++;
}
Random^ randomSeed=gcnew Random();
randomNumber=randomSeed->Next(0,x);
/*txtQuestion->Text=Answer;*/
msg1=tempArray[randomNumber];
IndexNumber=msg->IndexOf(separator); // determine the position of the separator
//txtQuestion->Text= tempArray[randomNumber] +"starting position: "
// +IndexNumber.ToString() + " string length: " ;
txtQuestion->Text= msg1;
Question=msg->Remove(0,IndexNumber+1); //Delete the answer from the String array
Answer=msg->Remove (IndexNumber); //Delete the Question from the String Array
txtQuestion->Text=Question + " " + Answer->Length.ToString () ; //display the question
txtAnswer->Text=Answer;
/*String::IndexOf*/
}
finally
{
if ( sr )
delete (IDisposable^)sr;
}
}
catch ( Exception^ e )
{
// Let the user know what went wrong.
txtQuestion->Text= "The file could not be read:" ;
txtQuestion->Text= e->Message ;
}
}
private: System::Void btnA_Click(System::Object^ sender, System::EventArgs^ e)
{
if(Answer->Contains(btnA->Text))
txtQuestion->Text ="yes";
else
lblX1->Text ="X";
btnA->Enabled=false;
}
private: System::Void btnB_Click(System::Object^ sender, System::EventArgs^ e)
{
if(Question->Contains(btnB->Text))
txtQuestion->Text ="yes";
else
lblX1->Text ="X";
btnB->Enabled=false;
}
private: System::Void btnC_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnD_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnE_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnF_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnG_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnH_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnI_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnJ_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnL_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnM_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnN_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnO_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnP_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnQ_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnR_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnS_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnT_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnU_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnV_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnX_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnY_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnW_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void btnZ_Click(System::Object^ sender, System::EventArgs^ e)
{ }
private: System::Void mnuExit_Click(System::Object^ sender, System::EventArgs^ e)
{
Application::Exit();
}
private: System::Void label2_TextChanged(System::Object^ sender, System::EventArgs^ e)
{ /*if(label2->Text="X")
label2->Text="X";
else
label3->Text="X";*/
}
};
}
This post has been edited by plipz: 05 October 2007 - 09:42 AM

New Topic/Question
Reply



MultiQuote




|