Button fix C++

I'm having a small problem with my button. I have the main done, but I am not able to figure out how to convert this code from VB. The ClickCount is the problem, and I'm not sure how to fix. The VB version is Dim ClickCount As Integer = 1, but how do I fix it to work in C++

#pragma once

namespace New {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ ButtonClick;
private: System::Windows::Forms::TextBox^ textBoxMessage;
protected:


protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#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->ButtonClick = (gcnew System::Windows::Forms::Button());
this->textBoxMessage = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// ButtonClick
//
this->ButtonClick->Location = System::Drawing::Point(104, 110);
this->ButtonClick->Name = L"ButtonClick";
this->ButtonClick->Size = System::Drawing::Size(75, 23);
this->ButtonClick->TabIndex = 0;
this->ButtonClick->Text = L"Click";
this->ButtonClick->UseVisualStyleBackColor = true;
this->ButtonClick->Click += gcnew System::EventHandler(this, &MyForm::ButtonClick_Click);
//
// textBoxMessage
//
this->textBoxMessage->Location = System::Drawing::Point(60, 59);
this->textBoxMessage->Name = L"textBoxMessage";
this->textBoxMessage->ReadOnly = true;
this->textBoxMessage->Size = System::Drawing::Size(165, 20);
this->textBoxMessage->TabIndex = 1;
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->textBoxMessage);
this->Controls->Add(this->ButtonClick);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion

private: System::Void ButtonClick_Click(System::Object^ sender, System::EventArgs^ e) {
textBoxMessage->Text="Hello World";

Dim ClickCount As Integer = 1

if Not ClickCount = 3 Then
ClickCount += 1
Else
ClickCount = 1
End If
Select Case ClickCount
Case Is = 1
TextMessage.BackColor = Color.Green
TextMessage.ForeColor = Color.White
Case Is = 2
TextMessage.BackColor = Color.Red
TextMessage.ForeColor = Color.Black
Case Is = 3
TextMessage.BackColor = Color.Orange
TextMessage.ForeColor = Color.Green

End Select

If Not ClickCount = 3 Then
ClickCount += 1
Else
ClickCount = 1
End If
Select Case ClickCount
Case Is = 1
Me.BackColor = Color.Red
Case Is = 2
Me.BackColor = Color.Blue
Case Is = 3
Me.BackColor = Color.Purple
End Select
}
};
}
Topic archived. No new replies allowed.