[Part1]C# - Introducing (Windows Form)

04/27/2010 12:06 ©Hyperlink#1
Part 1 - Introducing (WF)
Today we are gonna look at C# at introducing to it and the basics of windows form.

Lets start with what C# is?
Microsoft C# Visual Studio is a programming language wich you can use to create programs or different applications. You can work with windows forms, xml, sockets, consoles and much more.
C# is similar to C & C++ or java, but is not the same language and they all work different. They got different ways to work with things on.

Your very first script/program.
Lets take a look on a windows form application with a Messageboxes, a Textbox and a Button.

First you have to create a new project.
Choose "windows form application".
Now change the size so it fit, to what you want.
Now at the top of it create a label.
(Use the toolbox, you can choose it up in right it looks like some tools that you work with)
Click on the label and find "text".
Change the text "label1" to "Write: My First Script"
Now create a button.
Click on the button and find "text"
Change the text "Button1" to "Right Text?"
Now just place the button in the middle of the window.
Now create a textbox and make the size of it similar to this:
[ this is the textbox ]
Place the button beside the textbox, so it looks like this:
[ this is the textbox ][BUTTONHERE]
Now double on the Button.
Now find:
Code:
            InitializeComponent();
        }
Under it put a private string, because we need a text to input in textbox:
Code:
private string Text = "My First Script"
Now in the button you need to make a check for that the text is the same.
it could look like this:
Code:
if (Text == textBox1.Text) //Calls the private string from before
{
Now you will need to make a else, so repaste all in button, except the private void to this:
Code:
//Private void above this
{
if (Text == textBox1.Text) //Calls the private string from before
{
MessageBox.Show("You have created your first script successfull, congratulations.");
}
else
{
MessageBox.Show("Please type in: My First Script.");
}
}
Now press F5 to debug it and then type in the box:
Quote:
My First Script
Then click on OK.
And it should say:
You have created your first script successfull, congratulations.
And if you put other things or nothing it will say:
Please type in: My First Script.

Congratulations you have created your first C# script and windows form application.
But how do you save it as a program?
Click on build.
Then go to the release folder.
Then you got your files there.
You can take them to anywhere or put them in a rarfile, zipfile anything, so you can upload it or show friends etc.

I hope this was useful.

In Part 2, we will look at checkboxes.

[Only registered and activated users can see links. Click Here To Register...]



---------------------------------------
Any problems, post a reply or PM me.
05/03/2010 04:00 SigmaD#2
First of all thanks for the guide =) I read it and found you forgot to put the ; at the end of this line:
Code:
private string Text = "My First Script"
Also when I tried putting that line where you said, I kept getting the "Please type in: My First Script." message box even when I typed in the correct string. I don't know what private is used for or why you write it there but what I did was type this on the line before the if statement and it worked fine:
Code:
string Text = "My First Script";
Here's the whole code I used:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

                string Text = "My First Script";
                if (Text == textBox1.Text) 
                {
                    MessageBox.Show("You have created your first script successfull, congratulations.");
                }
                else
                {
                    MessageBox.Show("Please type in: My First Script.");
                }
            }
        }
    }
05/03/2010 04:10 ©Hyperlink#3
i used private string, because is set as private voids, really it dosn't matter alot.
05/03/2010 06:29 s.bat#4
Quote:
Originally Posted by ©Hyperlink View Post
i used private string, because is set as private voids, really it dosn't matter alot.
No, really it does matter a lot. You should read up on protecting instance data and encapsulation. You could even make a tutorial on it.
05/03/2010 07:36 TheGuyWithTheCodes#5
private:
For only same type

protected:
Derived or same types only

internal:
Same assembly(+external as long is same ass.)

protected internal
Combination of protected or internal. Not between them.

public
Any type, dosn't need to be same type, assymbly etc.
05/03/2010 08:31 ChingChong23#6
Quote:
Originally Posted by TheGuyWithTheCodes View Post
private:
For only same type

protected:
Derived or same types only

internal:
Same assembly(+external as long is same ass.)

protected internal
Combination of protected or internal. Not between them.

public
Any type, dosn't need to be same type, assymbly etc.
try reading a book instead of increasing your post count, it's a faster way to gain reputation.
05/03/2010 20:27 TheGuyWithTheCodes#7
Quote:
Originally Posted by ChingChong23 View Post
try reading a book instead of increasing your post count, it's a faster way to gain reputation.
they were discuss about the different types, I just gave them a clear answer.
05/03/2010 23:56 s.bat#8
Quote:
Originally Posted by TheGuyWithTheCodes View Post
they were discuss about the different types, I just gave them a clear answer.
Clear from all forms of intelligence? How's about letting someone with knowledge in the subject deter others from reading your post.
05/04/2010 00:39 TheGuyWithTheCodes#9
Quote:
Originally Posted by s.bat View Post
Clear from all forms of intelligence? How's about letting someone with knowledge in the subject deter others from reading your post.
so you say my post are wrong?
and what do you know about my knowledge for programming?
05/04/2010 08:41 DarkMessiah#10
Quote:
Originally Posted by TheGuyWithTheCodes View Post
private:
For only same type

protected:
Derived or same types only

internal:
Same assembly(+external as long is same ass.)

protected internal
Combination of protected or internal. Not between them.

public
Any type, dosn't need to be same type, assymbly etc.
Quote:
Originally Posted by TheGuyWithTheCodes View Post
so you say my post are wrong?
and what do you know about my knowledge for programming?

private: denotes a member of a class that can only be accessed by the instance of the class that owns it

public: denotes a member of a class that can be accessed by anyone

protected: same as private, but used in class derivation

external: denotes a function that is defined in a loaded library or module (usually in a dll)

Code:
abstract Class FooBase
{
     protected int _var3;
}

public Class Foo:FooBase
{
     public int var1 = 0;
     private int _var2 = 0;

     public void setVar2(int num) { _var2 = num; }
     public void setVar3(int num) { _var3 = num; } //var3 is inherited from FooBase
}

int main(..)
{
     Foo fooInstance = new Foo();
     fooInstance.var1 = 2;
     [B][COLOR="Red"]fooInstance._var2 = 2;[/COLOR][/B] //Wrong way
     fooInstance.setVar2(2); //Right way
     [B][COLOR="red"]fooInstance._var3 = 2;[/COLOR][/B] //Wrong way
     fooInstance.setVar3(2); //Right way
}
post count means nothing. set a goal to release something productive, like a bot, instead of spamming the forums with "help". then people will respect you.
05/04/2010 20:28 TheGuyWithTheCodes#11
Quote:
Originally Posted by DarkMessiah View Post
private: denotes a member of a class that can only be accessed by the instance of the class that owns it

public: denotes a member of a class that can be accessed by anyone

protected: same as private, but used in class derivation

external: denotes a function that is defined in a loaded library or module (usually in a dll)

Code:
abstract Class FooBase
{
     protected int _var3;
}

public Class Foo:FooBase
{
     public int var1 = 0;
     private int _var2 = 0;

     public void setVar2(int num) { _var2 = num; }
     public void setVar3(int num) { _var3 = num; } //var3 is inherited from FooBase
}

int main(..)
{
     Foo fooInstance = new Foo();
     fooInstance.var1 = 2;
     [B][COLOR="Red"]fooInstance._var2 = 2;[/COLOR][/B] //Wrong way
     fooInstance.setVar2(2); //Right way
     [B][COLOR="red"]fooInstance._var3 = 2;[/COLOR][/B] //Wrong way
     fooInstance.setVar3(2); //Right way
}
post count means nothing. set a goal to release something productive, like a bot, instead of spamming the forums with "help". then people will respect you.
what do you know about my releases?
and what you just posted, is what i just said.
05/04/2010 20:34 DarkMessiah#12
Quote:
Originally Posted by TheGuyWithTheCodes View Post
what do you know about my releases?
and what you just posted, is what i just said.
I would assume, based off your posts, that your "releases" are simple private server scripts. Looking on that account, however, it says that you have no actual released content regarding anything.

and no, it is not quite what you stated, but i think i cleared up any confusion that you might have created.
05/04/2010 20:53 TheGuyWithTheCodes#13
Quote:
Originally Posted by DarkMessiah View Post
I would assume, based off your posts, that your "releases" are simple private server scripts. Looking on that account, however, it says that you have no actual released content regarding anything.

and no, it is not quite what you stated, but i think i cleared up any confusion that you might have created.
then you maybe should look up at my old accounts.
I released about 3 sources.
+ im on my 4th.
05/05/2010 00:03 DarkMessiah#14
Quote:
Originally Posted by TheGuyWithTheCodes View Post
then you maybe should look up at my old accounts.
I released about 3 sources.
+ im on my 4th.
source = pserver = garbage then.

i have not seen a full server source worth anything that has been released. the one that comes closest is saint's basics that he has out written in c#. the rest are buggy garbage, which if you look back to my previous post, i've assumed already that your "contributions" only include crappy server scripts and such. And besides, why have multiple accounts?
05/05/2010 02:59 s.bat#15
Quote:
Originally Posted by TheGuyWithTheCodes View Post
what you just posted, is what i just said.
Hardly! What you posted was some of the most dreadfully incoherent rubbish I've ever read! You would have been much better off copy and pasting from this site: [Only registered and activated users can see links. Click Here To Register...]