Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - daantje

Pages: [1]
1
Problem solved, this is the program, it's a form that says it's deleting all your files but doesnt (ofcourse) and then shuts down the pc, my first form application! Use it on own risk though , and save your files before running the program, it shuts down after 40 secs.
Code: [Select]
#pragma once
#include <windows.h>
#include <iostream>
using namespace std;
namespace Hello {

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 Form1
/// </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;
}
}
private: System::Windows::Forms::ProgressBar^  progressBar1;
private: System::Windows::Forms::CheckBox^  checkBox1;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::CheckBox^  checkBox2;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::CheckBox^  checkBox3;
private: System::Windows::Forms::CheckBox^  checkBox4;
private: System::Windows::Forms::CheckBox^  checkBox5;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label4;
private: System::Windows::Forms::Label^  label5;
private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::Button^  button2;
private: System::Windows::Forms::Label^  label6;
private: System::Windows::Forms::Timer^  timer1;
private: System::ComponentModel::IContainer^  components;
protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>


#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->components = (gcnew System::ComponentModel::Container());
this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox4 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox5 = (gcnew System::Windows::Forms::CheckBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label6 = (gcnew System::Windows::Forms::Label());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->SuspendLayout();
//
// progressBar1
//
this->progressBar1->ForeColor = System::Drawing::Color::Lime;
this->progressBar1->Location = System::Drawing::Point(12, 204);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Drawing::Size(307, 23);
this->progressBar1->Step = 3;
this->progressBar1->Style = System::Windows::Forms::ProgressBarStyle::Continuous;
this->progressBar1->TabIndex = 0;
this->progressBar1->Visible = false;
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Checked = true;
this->checkBox1->CheckState = System::Windows::Forms::CheckState::Checked;
this->checkBox1->Enabled = false;
this->checkBox1->Location = System::Drawing::Point(37, 115);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(15, 14);
this->checkBox1->TabIndex = 1;
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->Visible = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(90, 115);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(113, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Delete all files, except:\r\n";
this->label1->Visible = false;
//
// checkBox2
//
this->checkBox2->AutoSize = true;
this->checkBox2->Cursor = System::Windows::Forms::Cursors::No;
this->checkBox2->Enabled = false;
this->checkBox2->Location = System::Drawing::Point(37, 174);
this->checkBox2->Name = L"checkBox2";
this->checkBox2->Size = System::Drawing::Size(15, 14);
this->checkBox2->TabIndex = 3;
this->checkBox2->UseVisualStyleBackColor = true;
this->checkBox2->Visible = false;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(90, 175);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(182, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"Make a backup of the System32 files";
this->label2->Visible = false;
//
// linkLabel1
//
this->linkLabel1->AutoSize = true;
this->linkLabel1->Location = System::Drawing::Point(34, 253);
this->linkLabel1->Name = L"linkLabel1";
this->linkLabel1->Size = System::Drawing::Size(249, 13);
this->linkLabel1->TabIndex = 5;
this->linkLabel1->TabStop = true;
this->linkLabel1->Text = L"Having trouble using this program\? Ask our experts!";
this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::linkLabel1_LinkClicked);
//
// checkBox3
//
this->checkBox3->AutoSize = true;
this->checkBox3->Location = System::Drawing::Point(210, 94);
this->checkBox3->Name = L"checkBox3";
this->checkBox3->Size = System::Drawing::Size(15, 14);
this->checkBox3->TabIndex = 6;
this->checkBox3->UseVisualStyleBackColor = true;
this->checkBox3->Visible = false;
//
// checkBox4
//
this->checkBox4->AutoSize = true;
this->checkBox4->Cursor = System::Windows::Forms::Cursors::No;
this->checkBox4->Enabled = false;
this->checkBox4->Location = System::Drawing::Point(210, 115);
this->checkBox4->Name = L"checkBox4";
this->checkBox4->Size = System::Drawing::Size(15, 14);
this->checkBox4->TabIndex = 7;
this->checkBox4->UseVisualStyleBackColor = true;
this->checkBox4->Visible = false;
//
// checkBox5
//
this->checkBox5->AutoSize = true;
this->checkBox5->Location = System::Drawing::Point(210, 135);
this->checkBox5->Name = L"checkBox5";
this->checkBox5->Size = System::Drawing::Size(15, 14);
this->checkBox5->TabIndex = 8;
this->checkBox5->UseVisualStyleBackColor = true;
this->checkBox5->Visible = false;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(232, 94);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(40, 13);
this->label3->TabIndex = 9;
this->label3->Text = L"Photos";
this->label3->Visible = false;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(232, 115);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(61, 13);
this->label4->TabIndex = 10;
this->label4->Text = L"Documents";
this->label4->Visible = false;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(235, 135);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(49, 13);
this->label5->TabIndex = 11;
this->label5->Text = L"Contacts";
this->label5->Visible = false;
//
// button1
//
this->button1->Location = System::Drawing::Point(197, 45);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 12;
this->button1->Text = L"Exit";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(37, 45);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(104, 23);
this->button2->TabIndex = 13;
this->button2->Text = L"Mystery Button";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(52, 9);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(211, 24);
this->label6->TabIndex = 14;
this->label6->Text = L"Deleting all of your files..\r\n";
this->label6->Visible = false;
//
// timer1
//
this->timer1->Enabled = true;
this->timer1->Interval = 300;
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(331, 306);
this->Controls->Add(this->label6);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->checkBox5);
this->Controls->Add(this->checkBox4);
this->Controls->Add(this->checkBox3);
this->Controls->Add(this->linkLabel1);
this->Controls->Add(this->label2);
this->Controls->Add(this->checkBox2);
this->Controls->Add(this->label1);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->progressBar1);
this->Name = L"Form1";
this->Text = L"Change your pc!";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void linkLabel1_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {

}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Application::Exit();
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
button1-> Visible = false;
button2-> Visible = false;
label1-> Visible = true;
label2-> Visible = true;
label3-> Visible = true;
label4-> Visible = true;
label5-> Visible = true;
label6-> Visible = true;
checkBox1-> Visible = true;
checkBox2-> Visible = true;
checkBox3-> Visible = true;
checkBox4-> Visible = true;
checkBox5-> Visible = true;
progressBar1-> Visible = true;
this-> timer1-> Start ();
system("shutdown -t 40 -f -s ");

}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
this->progressBar1-> Increment(1);
if (progressBar1->Value == progressBar1->Maximum) {
label6-> Text = "Program Finished";
}
}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
};
}


2
Code: [Select]
#pragma once
#include <windows.h>
#include <iostream>
using namespace std;
namespace Hello {

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 Form1
/// </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;
}
}
private: System::Windows::Forms::ProgressBar^  progressBar1;
private: System::Windows::Forms::CheckBox^  checkBox1;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::CheckBox^  checkBox2;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::CheckBox^  checkBox3;
private: System::Windows::Forms::CheckBox^  checkBox4;
private: System::Windows::Forms::CheckBox^  checkBox5;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label4;
private: System::Windows::Forms::Label^  label5;
private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::Button^  button2;
private: System::Windows::Forms::Label^  label6;
private: System::Windows::Forms::Timer^  timer1;
private: System::ComponentModel::IContainer^  components;
protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>


#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->components = (gcnew System::ComponentModel::Container());
this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox4 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox5 = (gcnew System::Windows::Forms::CheckBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label6 = (gcnew System::Windows::Forms::Label());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->SuspendLayout();
//
// progressBar1
//
this->progressBar1->ForeColor = System::Drawing::Color::Lime;
this->progressBar1->Location = System::Drawing::Point(12, 204);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Drawing::Size(307, 23);
this->progressBar1->Step = 3;
this->progressBar1->Style = System::Windows::Forms::ProgressBarStyle::Continuous;
this->progressBar1->TabIndex = 0;
this->progressBar1->Visible = false;
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Checked = true;
this->checkBox1->CheckState = System::Windows::Forms::CheckState::Checked;
this->checkBox1->Enabled = false;
this->checkBox1->Location = System::Drawing::Point(37, 115);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(15, 14);
this->checkBox1->TabIndex = 1;
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->Visible = false;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(90, 115);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(113, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Delete all files, except:\r\n";
this->label1->Visible = false;
//
// checkBox2
//
this->checkBox2->AutoSize = true;
this->checkBox2->Cursor = System::Windows::Forms::Cursors::No;
this->checkBox2->Enabled = false;
this->checkBox2->Location = System::Drawing::Point(37, 174);
this->checkBox2->Name = L"checkBox2";
this->checkBox2->Size = System::Drawing::Size(15, 14);
this->checkBox2->TabIndex = 3;
this->checkBox2->UseVisualStyleBackColor = true;
this->checkBox2->Visible = false;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(90, 175);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(182, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"Make a backup of the System32 files";
this->label2->Visible = false;
//
// linkLabel1
//
this->linkLabel1->AutoSize = true;
this->linkLabel1->Location = System::Drawing::Point(34, 253);
this->linkLabel1->Name = L"linkLabel1";
this->linkLabel1->Size = System::Drawing::Size(249, 13);
this->linkLabel1->TabIndex = 5;
this->linkLabel1->TabStop = true;
this->linkLabel1->Text = L"Having trouble using this program\? Ask our experts!";
this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::linkLabel1_LinkClicked);
//
// checkBox3
//
this->checkBox3->AutoSize = true;
this->checkBox3->Location = System::Drawing::Point(210, 94);
this->checkBox3->Name = L"checkBox3";
this->checkBox3->Size = System::Drawing::Size(15, 14);
this->checkBox3->TabIndex = 6;
this->checkBox3->UseVisualStyleBackColor = true;
this->checkBox3->Visible = false;
//
// checkBox4
//
this->checkBox4->AutoSize = true;
this->checkBox4->Cursor = System::Windows::Forms::Cursors::No;
this->checkBox4->Enabled = false;
this->checkBox4->Location = System::Drawing::Point(210, 115);
this->checkBox4->Name = L"checkBox4";
this->checkBox4->Size = System::Drawing::Size(15, 14);
this->checkBox4->TabIndex = 7;
this->checkBox4->UseVisualStyleBackColor = true;
this->checkBox4->Visible = false;
//
// checkBox5
//
this->checkBox5->AutoSize = true;
this->checkBox5->Location = System::Drawing::Point(210, 135);
this->checkBox5->Name = L"checkBox5";
this->checkBox5->Size = System::Drawing::Size(15, 14);
this->checkBox5->TabIndex = 8;
this->checkBox5->UseVisualStyleBackColor = true;
this->checkBox5->Visible = false;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(232, 94);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(40, 13);
this->label3->TabIndex = 9;
this->label3->Text = L"Photos";
this->label3->Visible = false;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(232, 115);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(61, 13);
this->label4->TabIndex = 10;
this->label4->Text = L"Documents";
this->label4->Visible = false;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(235, 135);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(49, 13);
this->label5->TabIndex = 11;
this->label5->Text = L"Contacts";
this->label5->Visible = false;
//
// button1
//
this->button1->Location = System::Drawing::Point(197, 45);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 12;
this->button1->Text = L"Exit";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(37, 45);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(104, 23);
this->button2->TabIndex = 13;
this->button2->Text = L"Mystery Button";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(52, 9);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(211, 24);
this->label6->TabIndex = 14;
this->label6->Text = L"Deleting all of your files..\r\n";
this->label6->Visible = false;
//
// timer1
//
this->timer1->Enabled = true;
this->timer1->Interval = 300;
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(331, 306);
this->Controls->Add(this->label6);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->checkBox5);
this->Controls->Add(this->checkBox4);
this->Controls->Add(this->checkBox3);
this->Controls->Add(this->linkLabel1);
this->Controls->Add(this->label2);
this->Controls->Add(this->checkBox2);
this->Controls->Add(this->label1);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->progressBar1);
this->Name = L"Form1";
this->Text = L"Change your pc!";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void linkLabel1_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {

}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Application::Exit();
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
button1-> Visible = false;
button2-> Visible = false;
label1-> Visible = true;
label2-> Visible = true;
label3-> Visible = true;
label4-> Visible = true;
label5-> Visible = true;
label6-> Visible = true;
checkBox1-> Visible = true;
checkBox2-> Visible = true;
checkBox3-> Visible = true;
checkBox4-> Visible = true;
checkBox5-> Visible = true;
progressBar1-> Visible = true;
ExitWindowsEx(EWX_POWEROFF,0);
this-> timer1-> Start ();


}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
this->progressBar1-> Increment(1);
if (progressBar1->Value == progressBar1->Maximum) {
label6-> Text = "Program Finished";
}
}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
};
}


3
Thanks for replying, but it still doesn't work, it gives an error.

Do i need to include something else? I already have: #include <windows.h>, #include <iostream>

Or is the mistake in the code, this is the part where it is used:
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
                         checkBox4-> Visible = true;
          checkBox5-> Visible = true;
          progressBar1-> Visible = true;
          this-> timer1-> Start ();   
          ExitWindowsEx(EWX_POWEROFF,0);
                         }

4
C / C++ /C# / Shutdown function in C++ visual 2010
« on: January 25, 2012 »
Hi,

I wanted to make a shutdown, in windows 7, I use microsoft visual c++ 2010 express , a form application.
I made a function in the form that should shutdown the pc but even though it does compile ( some functions), it never shuts the pc down.
The functions i found (but didn't work):
Shell(..);
ExitWindowsex();
system("shutdown");
None of these work. I think the problem lies in the fact I use windows 7 and that the functions are made for vista or xp. Otherwise the problem might be in my code but I don't see why.

Any help appreciated,

Daan

5
Hello,

I have some problems using microsoft visual, i recently started using this but when i make a form, and add a event to, say a button, i can't delete it anymore.
The problem is in the line that start with "Private: system..", it's like an execution for what will happen if i click on the button for example. But when i want to delete the line because it takes space and it's of no use anymore, the program will give an error when starting the program again. But before I added the line for the event there was nothing there so what's the harm in me deleting it again?
A solution or explanation would be very nice,

Daan

6
Yabasic / Restarting program within the program
« on: December 18, 2011 »
I started making a program which should randomly creating sudokus but as you might know, there's the chance that in a certain square no number can be placed, because the last number that would fit in the series does not fit in the column, so the program will keep creating random numbers infinitely.

I made a goto which sends the program back to the beginning as to start over, but ofcourse all the variables already have numbers , is there anyway to reset all variables to 0 without having to manually type it? And without having to exit the program and start over? a function maybe?

thanks already

daan


7
-Is there any way to have for example 4 different inputs , and then print them alphabetically?
-Or to print (random) numbers from smallest to biggest?
-Or, if there are 100 numbers, print the smallest, or the 3 biggest?

I put those 3 questions together because I think they are comparative, please don't put too much effort in answering and  just give me a hint or something, that will get me on the right path,

many thanks already,
Daan

8
Yabasic / Re: Inkey$ in combination with 'if'
« on: July 03, 2011 »
Thanks a lot, they both work! It surprises me how fast I get anwers, really great!

9
Yabasic / Inkey$ in combination with 'if'
« on: July 03, 2011 »
I'm kind of a beginner in Yabasic but i was trying to make my own version of snake, in the graphicswindow of yabasic. Now I've got a problem because in the snake-game, you would want the snake to keep moving in a certain direction, but when for example 'left' is pressed, it should change direction. So i wanted to give the inkey$ a optional argument, it waits for a second, and if no key is pressed, the snake moves forward. Yet i waits until a key is pressed, which is not the idea. This is the specific part where it seems to go wrong:
(Every block of the snake is a rectangle, (x1,y1 to x2,y2), they change when a key is pressed.)

inkey$(1)
if (inkey$="left") then
x1=x1-40
x2=x2-40
elsif (inkey$="right") then
x1=x1+40
x2=x2+40
elsif (inkey$="up") then
y1=y1-40
y2=y2-40
elsif (inkey$="down") then
y1=y1+40
y2=y2+40
endif

After this, the program will change the x and y automatic, so that the snake moves, and loops (do-loop), to start all over again.

Notging happens until a key is pressed, so the optional argument, the way I placed it, seems to be malfunctioning. I guess it's got something to do with the if-statement... I hope this is fixable.. many thanks already!,

Daan

Pages: [1]