DFBarracks - Forums




Delta Force Barracks Forums - Powered by XMB 1.9.11
Delta Force Barracks Forums
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: Tutorial Level: Beginner: Add to your first program (Getting used to Code)
bullet magnet
Captain
****


Avatar


Posts: 263
Registered: 6-26-2005
Member Is Offline

Mood: Modding

[*] posted on 6-27-2007 at 02:51 PM
Tutorial Level: Beginner: Add to your first program (Getting used to Code)


I hope you have read the first tutorial, we are now going to add to that.

1.) We have already discussed how to add controls (button, textbox, label to the form), just drag and drop.

2.) First lets creat our form, or the backbone of the program, File, New, WindowsApplication.

3.) Click on the form, only once because twice will take you to code view.Then go to the right to the properties tab.

Play with the settings, they are prety self explanatory.

4.) Now add a TextBox, Label, and Button. What our program is going to do is let the user type something in the TextBox, press the button, and make that text appear on the label.

5.) Think about what your program needs to do and take it one step at a time. First the user types something, that takes no coding, then he presses the button, and makes it go on the Label, this takes coding.

6.) Double click on the button on the form, so that you are in code-view. Under all the Private Sub Button1_Click crap, type this code:

Code:
[size=3]Label1.Text = TextBox1.Text[/size]


Simple and Self-explanatory right? It simply sets the Label's text equal to the TextBox text when the button is being clicked.

7.) Run your program using the green arrow near the top.

Type something in the TextBox, press the Button, and TaDa!!!

8.) Now lets stretch this out a bit since this lesson IS about coding. We are now going to "Hide" the TextBox.

9.) Under the Label1.Text = TextBox1.Text

Type this code:

Code:
[size=3]TextBox1.Hide[/size]


Again, self explanatory, run the program, it will disappear when the button is clicked.

10.) OK, now lets get our TextBox back!

Add a new button by swithcing back to designer mode using the tabs

Double click the button you just added, and lets add some more code.

Below Private Sub Button1_Click blah blah blah type

Code:
[size=3]TextBox1.Show[/size]


More simple code that simply reshows our TextBox.

11.) Many programs use more than one form, so lets add one more, go to Project at the top, then Add Windows Form, this will add a new form, form2.

12.) Make a new button on the form, and in the code, type

Code:
[size=3]Form2.Show[/size]


This obviously shows Form2.

You can also close the first form by typing

Code:
[size=3]Me.Close[/size]


"Me" simply means you are coding in that particular form.


Now you can add more buttons, textboxes, labels, and simply change the code around, hide them, show them, the possibilites are endless.


Check in for more,

Bullet Magnet






View user's profile View All Posts By User

  Go To Top

Powered by XMB 1.9.11
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 15] [PHP: 96.4% - SQL: 3.6%]












Copyright © 2002 - 2008 All Rights Reserved - DFBarracks.com
Site Design by A.Bullet - ScreamingDemon.com