Register for your free account! | Forgot your password?

Go Back   elitepvpers > Conquer Online 2 > CO2 Main - Discussions / Questions > CO2 Programming
You last visited: Today at 16:00

  • Please register to post and access all features, it's quick, easy and FREE!


[Part1]C# - Introducing (Windows Form)

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2010
Posts: 109
Received Thanks: 55
[Part1]C# - Introducing (Windows Form)

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.





---------------------------------------
Any problems, post a reply or PM me.



©Hyperlink is offline  
Thanks
1 User
Old 05/03/2010, 04:00   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 59
Received Thanks: 58
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.");
                }
            }
        }
    }


SigmaD is offline  
Thanks
1 User
Old 05/03/2010, 04:10   #3
 
elite*gold: 0
Join Date: Apr 2010
Posts: 109
Received Thanks: 55
i used private string, because is set as private voids, really it dosn't matter alot.
©Hyperlink is offline  
Old 05/03/2010, 06:29   #4
 
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
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.


s.bat is offline  
Old 05/03/2010, 07:36   #5
 
elite*gold: 0
Join Date: May 2010
Posts: 122
Received Thanks: 24
private:
For only same type

protected:
Derived or same types only

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

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

public
Any type, dosn't need to be same type, assymbly etc.
TheGuyWithTheCodes is offline  
Old 05/03/2010, 08:31   #6
 
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 79
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 ***.)

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.
ChingChong23 is offline  
Thanks
2 Users
Old 05/03/2010, 20:27   #7
 
elite*gold: 0
Join Date: May 2010
Posts: 122
Received Thanks: 24
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.
TheGuyWithTheCodes is offline  
Old 05/03/2010, 23:56   #8
 
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
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.
s.bat is offline  
Old 05/04/2010, 00:39   #9
 
elite*gold: 0
Join Date: May 2010
Posts: 122
Received Thanks: 24
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?
TheGuyWithTheCodes is offline  
Old 05/04/2010, 08:41   #10
 
elite*gold: 0
Join Date: Jan 2007
Posts: 177
Received Thanks: 57
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.
DarkMessiah is offline  
Old 05/04/2010, 20:28   #11
 
elite*gold: 0
Join Date: May 2010
Posts: 122
Received Thanks: 24
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.
TheGuyWithTheCodes is offline  
Old 05/04/2010, 20:34   #12
 
elite*gold: 0
Join Date: Jan 2007
Posts: 177
Received Thanks: 57
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.
DarkMessiah is offline  
Thanks
1 User
Old 05/04/2010, 20:53   #13
 
elite*gold: 0
Join Date: May 2010
Posts: 122
Received Thanks: 24
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.
TheGuyWithTheCodes is offline  
Old 05/05/2010, 00:03   #14
 
elite*gold: 0
Join Date: Jan 2007
Posts: 177
Received Thanks: 57
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?
DarkMessiah is offline  
Old 05/05/2010, 02:59   #15
 
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
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: Accessibility Levels (C#)


s.bat is offline  
Reply



« CO2 effect folder question. pls help. | Correct way to handle speedhack »

Similar Threads
[Part3]C# - TextEditor (Windows Form)
04/28/2010 - CO2 Programming - 0 Replies
Now we will look at some more advanced things like creating a text editor, with load/save files. First create a windowsformapplication. Make sure you name it: TextEditor Now delete the "Form1.cs". Now right click at your solution and choose:...
[Part2]C# - Checkboxes (Windows Form)
04/27/2010 - CO2 Programming - 5 Replies
Part 2 - Checkboxes Okay now you have learned about buttons and textboxes at basics. What is checkboxes used for? A checkbox is used to check for more choices. You can use it for making vote buttons, using them instead putting 100Buttons or...
windows form
04/20/2010 - CO2 PServer - Discussions / Questions - 4 Replies
okay i made this windows form application. But how do i save it as a program, so i can make it to a rar file, so it can be used. lol is an easy question, dont flame me or ill report. And close this after i got answer.
Image on Windows Form,
02/08/2010 - CO2 PServer - Discussions / Questions - 6 Replies
Anyone knows how to add the very small Image, of an Application Icon on a C# Windows form Application, Like, http://img237.imageshack.us/img237/5849/imageke.png flako27-
Windows form...
11/15/2008 - CO2 PServer - Discussions / Questions - 9 Replies
//



All times are GMT +2. The time now is 16:00.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.