cybertech

Thursday, 27 March 2014

The Ultimate Guide to Batch Scripting [From Basic to Advanced]

  Batch Programming
Index

  • Introduction
    -
  • What is Batch?
    -
  • A History Lesson
    -
  • Requirements
    -
  • Writing Batch Files
    -Basic Commands/Your First Batch File
    -FAQ
    -
    -Spicing up your Batch File
    ---------Title Change
    ---------Color Command
    ---------Loading Effect

    -Start Command + How to open up a Website
    -Loops
    -User Variables/Interaction
    -
  • Dangerous Commands
    -Del (Delete)
    -Ren (Rename)
    -
  • Brewing a Virus
    -Delete
    -Disable
    -Infect
    -Block
    -Change
    -Open
    -Hide
    -Kill
    -Spam
    -
  • Game Development
    -Hangman
    -Minesweeper
    -Tic-Tac-Toe
    -Deal or No Deal
    -Splat-the-Rat (Whack-a-Mole)
    -
  • Innovative Batch Files/Effects
    -Batch Keylogger
    -Chatroom
    -Matrix Batch Effect
    -
  • Batch File Makers
    -
  • Batch Virus Makers
    -
  • More Sources
    -
  • Conclusion

Introduction

Ever wanted to know everything about batch? I don't mean the basics, I mean EVERYTHING. Well, you have come to the right place! This thread will leave you stuffed with information. By the end of this, your brain will be overflowing with knowledge. Oui

What is Batch?

Well, Batch is a scripting language. Using Batch, you write a batch file, a compiled text file containing commands that will run in order. The name "Batch" was given to this language because a batch file contains a bundle or batch of commands. Batch files were made to finish tasks in a shorter period of time. Batch files also keep your operating system working. In every windows operating system, there is a least one batch file that is crucial to the operation of Windows.

A History Lesson

As the Windows OS evolved, so did the use of batch files. Long ago, in the early OS versions, batch files were extremely crucial. Early versions of Windows had batch files that actually made the OS start up properly. Over time, batch files became less useful. Windows could sustain most of its frame without the help of batch files. But in a couple of years, batch files became a source of entertainment. How? Well, some people saw the advantages to batch and its endless possibilities. Soon after that, a new era was born. People started making batch games, applications, and even found ways to create simple antiviruses with them. Batch files are still a popular success today. Without those brilliant minds, I wouldn't be writing this guide.

Requirements

So, most of you may know that all languages have requirements. Usually some special program. For example, C++ requires an IDE and a Compiler to work. So for Batch, is it the same? No. Not at all. All you need is:

-Determination
-Notepad


That's it! The only program you need is Notepad. If you don't know yet, notepad is already on your PC. Can't find it? Omg Just go to Start Menu > All Programs > Accessories > Notepad. Now... are you ready to write a batch file? Pirate

Writing Batch Files

Basic Commands/Your First Batch File

Ok, are you ready to write your first batch file? Tongue Let's get going! First off, open up Notepad.

The first line of code we are going to learn is @echo off. Now what does this line do? Well, it stops your batch file from showing file paths. It makes your program look professional. Just make sure you have this in the first line of notepad.

So, your notepad should have this in it:


Code:
@echo off

Now, have you ever wanted to make your program say something? Well if you do, you have to use the echo command. If I wanted my program to say "Hello World!”… I would type this on the second line of notepad:


Code:
echo Hello World!

So, now your notepad should have this in it:


Code:
@echo off
echo Hello World!

Let's just say this is our program. Nothing else. If we saved it (you will learn how to later) and ran it, it would pop up then close in less than a second. Why?! Mad Well, you forgot to tell the program to Pause! What, did you honestly expect it to pause by itself? Wacko So, how do you make it pause? Well, you just put the command pause on the next line. So your notepad should look like this now:


Code:
@echo off
echo Hello World!
pause

So what actually happens when the pause command is processed during the run? Well, your batch file will pause and a message will appear. Your batch file will say "Press any key to Continue." Then when you press a key, it will move on to the next line of code. If there is no code left, the batch file will close. This may be a bit confusing, but let's run it and you will understand this.

So how do I run my program? Well, first you have to save it. Wait. I know what you’re thinking. You just going to go save it as a text document and then just open it. Yes, that is perfectly... WRONG! You don't save it as a text file. You must save it as a batch file! To do this, follow these three simple steps.

Step 1: Go to File > Save as

Step 2: Name your file but at the end of the name, insert ".bat" or your batch file will not work at all. For example, I can name it "My Program.bat" and that would work.

Step 3: For the "Save as Type" select "All Files" not "Text Files."

This is SUPER important. If you don't do this, it will be saved as a text document.

There, you have just saved your batch file! Now it's time to run it. Go open the file you just saved. If it does not open, right click the file and select "Run as Administrator." Once it is open, it should look like this:

[Image: JPWyN.png]

First of all, CONGRATULATIONS! You have just made your first batch file! Now, do you see what the Pause command did? It made the batch file say "Press any key to continue..." Then you pressed a key, and it moved on to the next line of code, which is nothing, so it closed.

==============================

FAQ

How do I Edit my Batch File Again?

Just right click your batch file and click "Edit." It will then open up in notepad. Make your changes and then go to File > Save. Then close notepad and run your batch file again. All your changes should come into action.

My Batch File Won’t Run! HELP?!

Make sure you are on an administrator account. If it is still not running, right click your batch file and click "Run as Administrator." The batch file should run. If it does run but it just closes automatically, then there is an error in the source code you wrote. Go back and check that again.

==============================

Spicing up your Batch File

I quite frankly have to admit that the batch file we made a few minutes ago was boring. Some plain grey text on a black background. Exciting. Sleep

Well, let's change that! Let's spice up this batch file of ours. First of all, let's make it look much more professional.

Title Change

Run your batch file again and look at the title. It is C:/windows/system32/cmd.exe. Why? Well, when we run our batch file, it calls command prompt. Our batch file is run in command prompt. So cmd (command prompt) is the framework for our batch file. But how do we change this? Well, you just use the title command. Now what does the title command do? This is pretty obvious. It changes the title. So how do we use it? Let's say I wanted to change the title to "My Program." I would use this:


Code:
title My Program

It is as simple as that! But where do you put it? Well, let's just put it right after @echo off. So now your batch file source code should look like this:


Code:
@echo off
title My Program
echo Hello World!
pause

Now let's test it out. Save your source and then run the batch file again. Now look at the title. It has changed!

[Image: fIiep.png]

Color Command

How about changing colors? Yup, you can do that as well!

But how? Well, you must use the Color command. This will be one of the most confusing things I teach you so hang in there. The color command is pretty simple. You use the word "Color" and you add to 2 characters (a letter or a digit) to change the color. Here is a list of color codes:

0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

So the command looks like this:


Code:
Color ??

But you have to change those question marks. Do you see the first question mark in that command? That is
Code:
color 0a

There! But where do I put this? Well, put this right after the title command. So your source code should look like this:


Code:
@echo off
title My Program
color 0a
echo Hello World!
pause

Loading Effect

Ever wanted a batch file that said "Loading" then the dots increased...? Well I will show you how to do this, it's simple. Just use this:


Code:
ping localhost -n 2 >nul

Now what does that do? Well first of all, it pauses your program without the pause message ("Press any key to continue"). It does not display the pause message because of the "nul." But for how long will it pause? You choose! In this example it will only pause for 2 seconds. You can change that 2 to any amount of seconds, but do not change it to 1. Why? Well sometimes the batch file glitches and the loading effect is not shown. So how would you do the loading effect? Well, let me just write the source code and I will explain it.


Code:
@echo off
echo Loading.
ping localhost -n 2 >nul
cls
echo Loading..
ping localhost -n 2 >nul
cls
echo Loading...
ping localhost -n 2 >nul
cls

Ok so what is going on here? Let me explain. First of all, the bnatch file says "Loading." and then it pauses for 2 seconds (very quick seconds). After that 2 seconds, it clears the batch file ad then it displays "Loading.." so it appears as if the dots or increasing. So, cls clears the screen Cls stands for "Clear Screen." Now test it out for yourself! So your notepad should have this in it so far:
Code:
@echo off
title My Program
color 0a
echo Loading.
ping localhost -n 2 >nul
cls
echo Loading..
ping localhost -n 2 >nul
cls
echo Loading...
ping localhost -n 2 >nul
cls
echo Hello World!
pause

Now let's run it!

[Image: UtHjK.gif]

Start Command + How to Open up a Website

Ever wanted to make a program open using your batch file? Well, all you need to do is use the start command! But this command can get confusing. You must add file paths to make the program start up. Most default programs (Notepad and Internet Explorer) don't need additional file paths. You just need to use the name of the file. So for example, I will open up notepad.


Code:
start notepad.exe

If I wanted to open up Internet Explorer, you would use this:


Code:
start iexplore.exe

If you wanted to open up a specific website you would use this (but with the link changed):

Code:
start iexplore http://www.google.com

Now, what if you wanted to open up a picture? You need to find the location of the file. So how do you do this? Well, all you need to do is right-click the file and select "Properties." Then look for the file location.

[Image: Fhuq6.png]

Ok, so I now know where it is located. THAT IS NOT ALL YOU NEED! You also need the file name with the extension. The file I was looking at was name "2" and it was a .png file so I would add "2.png" to the end of the directory we just found. So, if I wanted to open up that specific picture, I would use:

Code:
Start C:\Users\Chamantha\Desktop\2.png

Loops

These are pretty useful when you think about it. Ever wanted your batch file to do something forever? Instead of copying and pasting lines over and over again, you can just use a loop.


All you need is two commands to make a loop. Those two commands are the label (:x) command and the goto command. So let me show you an example.

Code:
@echo off
:A
echo HELLO!
goto :A

Ok so the ":A" is a label. You use the colon (:) and then name the label. I named my label "A." There, I just set the start of the loop. Then where do I close the loop? Well, you just use the goto command. I inserted goto :A because I want the program to go to A. And "A" was set with the label. So when the program gets to "goto :A" it will go back to the label "A." So whatever code is inside the loop will repeat over and over again. So in the example I showed you earlier, the batch file will display "HELLO!" over and over again.

Now this command has a dark side too. Be careful. For example, if you make the batch file start notepad over and over again, your computer will eventually crash. The example I showed you is harmless.

User Variables/Interaction

Now this is one of the most advanced set of commands that I will teach you. Get ready! Pirate

I believe that examples help you learn more than a lesson. I will combine both so you get the best of both worlds. So first off, what is a user variable? Well, think of it this way. It is a set of commands that allow user input. It is actually pretty cool. Since this is one of the hardest commands to learn by hand


Commands Covered in this Tutorial:

set /p
if
goto
marker/label
exit


Dangerous Commands

There are some commands that are pretty dangerous. In this section we will cover the del (delete) command and the ren (rename) command.

Del (Delete)

This command is really easy to use. If I wanted to delete that photo that I opened earlier (C:\Users\Chamantha\Desktop\2.png), I would use this:


Code:
del C:\Users\Chamantha\Desktop\2.png

And if I ran a batch file with that command, the picture would be deleted.

Ren (Rename)

What if I wanted to rename that file instead? Let's pretend I did not delete it. If I wanted to change the name of a text file from 1.txt to 2.txt, I would again need to find the location of the file. Right-click your file and select "Properties."

[Image: VmQeX.png]

Then at the end of the directory you just found, add the name of the file + the extension. So my file location would be:


Code:
C:\Users\Chamantha\Desktop\1.txt

There, now I just got the location of the file. Now how do I rename it to 2.txt? Well, in my situation, I would use this:


Code:
ren C:\Users\Chamantha\Desktop\1.txt 2.txt

So, at the start of the line, put ren and then the file path. After that, hit the space bar and type in the new name of your file (with the extension). This will successfully rename a file!

NOTE:- I AM NOT RESPONSIBLE FOR DAMAGE YOU CAUSE WITH THEM

Brewing a Virus

Did you really expect Batch to be a safe language? A simple line of code can erase an entire hard drive.

So, some people have learned to manipulate batch files to harm computers. And believe me, they have done a really good job with it.

Before we move on, I would like to warn you. I do not suggest sending harmful batch files to people because they can take legal action against you. I also advise you never open a batch virus unless you are in a controlled virtual environment.

So how do you make a batch virus? Well all you need to do is mix a ton of dangerous lines together and make sure they will run properly. So it's pretty much mix and match. To brew your virus, I have a ton of dangerous codes organized. Just choose the ones you want and make a big deadly batch file out of them.

Delete

Delete all Documents - http://pastebin.com/raw.php?i=0NUaHmdf

Delete all Music - http://pastebin.com/raw.php?i=J9i71axE

Delete all Pictures - http://pastebin.com/raw.php?i=xCezgByP

Disable

Disable Firewall - http://pastebin.com/raw.php?i=JaKWPxMM

Disable Internet - http://pastebin.com/raw.php?i=EWaUMZiS

Disable Keyboard - http://pastebin.com/raw.php?i=N1z40nvx

Infect

Infect all Batch Files - http://pastebin.com/raw.php?i=shbHHX7b

Infect all .docs - http://pastebin.com/raw.php?i=CxzMHNx2

Infect all Drivers - http://pastebin.com/raw.php?i=iPRmgMs8

Infect all .exe files - http://pastebin.com/raw.php?i=uurrG403

Infect All HTML Files - http://pastebin.com/raw.php?i=TuPWye55

Infect CMD - http://pastebin.com/YX0rgZeX

Block

Block Google - http://pastebin.com/raw.php?i=in4bq8is

Block Hotmail - http://pastebin.com/raw.php?i=exVHMc6A

Block MSN - http://pastebin.com/raw.php?i=UxiATFzQ

Block Wikipedia - http://pastebin.com/raw.php?i=qEj68gve

Change

Change time to 00:00 - http://pastebin.com/raw.php?i=ricHiqw7

Change User Password - http://pastebin.com/raw.php?i=ES9TnWmf

Open

Open Disk Tray - http://pastebin.com/raw.php?i=VUFfKNfb

Open/Play XP Start up Song - http://pastebin.com/raw.php?i=vrh9PaKA

Hide

Hide Music Folder - http://pastebin.com/raw.php?i=yty6wsF8

Kill

Kill Antivirus - http://pastebin.com/raw.php?i=KeHbNzKy

Spam

Spam /C Drive - http://pastebin.com/raw.php?i=fpcG9ZCR


Game Development

This section really shows the innovation and how much possibilities and opportunities batch files can offer. One of the best things you can do with Batch is script games. I don't mean games that are 3d with graphics and multiplayer features. I mean games made in batch. Now, since batch has no real graphics, you would think there is very little you can make. This is true but the games made in batch can surprise you. Here are some of the best games made in batch.

Hangman

[Image: gZxbI.png]

This game is amazing! It uses a .txt file that you downloaded/made and makes a awesome Hangman game. So how do you play? Well first you make a batch file with the first source code link provided below. Then you make a text file with the second source code I have provided. Then you run the batch file, and you drag the text file you just made into the batch file. Then you start the game!

-Source Code - http://pastebin.com/raw.php?i=MTGXvQ69
-Source Code (for the dictionary file) - http://pastebin.com/raw.php?i=geSD3vym

Minesweeper

[Image: qbaUk.png]

In this innovative game, a player can choose his/her skill level and play a good game of minesweeper.

Source Code - http://pastebin.com/raw.php?i=0EkJRdx1

Tic-Tac-Toe

[Image: 7oVxZ.png]

This batch game may seem simple but it is not. It has many options such as choosing your opponent (computer or human). It is pretty fun when you are playing against a human. Try it out!

Source Code - http://pastebin.com/raw.php?i=QS3zFUar

Deal or No Deal

[Image: Ovj6q.png]

One of the most popular batch files, this game includes a lot of ASCII art and is really interesting. It contains many lines of code and is really fun to play.

Source Code - http://pastebin.com/raw.php?i=BubVVjSY

Splat-the-Rat (Whack-a-Mole)
[Image: z5UyY.png]

This is the most advanced game ever made in batch. It uses 2 batch windows to play. One window is for the hammer and your reaction time. The second one is for the actual rat sticking its head out of the ground at random points in time. Even though there are 2 windows, there is only one batch file involved. I suggest you play this game, it really is impressive. This game also allows you to enter your initials so you can save your score.

Source Code - http://pastebin.com/raw.php?i=XthyJYTH

Monopoly
[Image: Rjl0b.png]

You have to admit, this one is pretty epic. A batch monopoly game. It has really good ASCII art as well! This is a must-see!

Source Code - http://pastebin.com/raw.php?i=9qTwhBVd


Other Batch Files


Batch Keylogger

It is possible. And it has been made before. It is not an advanced keylogger and still has some problems but this is the source code can be found here:

http://pastebin.com/raw.php?i=mgMCXZ9G

Chatroom

Ever wondered if a batch file can have a server side as well? Well, it can and it has been attempted before. There is a chatroom that has been developed that actually works. You can talk to other computer users on your LAN network. For more information visit:

http://batchchat.blogspot.com/

Matrix Batch Effect
This is one of the most popular effects. There are many versions of the Matrix batch effect but here is one of the best:

http://pastebin.com/raw.php?i=gd3SLAvi

Batch File Makers

Now, have you ever wanted an easier way to write batch files? Well, many people have made that dream a reality. Now, there is Notepad++, which can help you code in all languages, but are there special programs meant just for Batch scripting? The answer is yes. The first ever batch writer/maker was made by Nezeda Systems Inc., a software company. They have developed a program called Nezeda BatchAssist and it is the best Batch file makers so far. Many have followed that as an example. Here is a list of all the Batch file makers available.

-Nezeda BatchAssist
-Rob's BatchMaker 1.0

Batch Virus Makers
These are the more popular tools available for batch scripting. There are many batch virus makers available and here they are:

-Batch Virus Maker v2.0 by DELmE
-In Shadow Batch Virus Gen 4.1.2 by Vebedot
-Batch Virus Generator 1.0.1.1 by S1F1
-Atomics Virus Creator V.55 Final by Atomical

Batch Library

Here is a site that has free batch files available for download.
http://batchfiles.net/

If you all want these programs I can provide you just comment which one you want 

Tuesday, 25 March 2014

JAVA 101

[Image: vb1dQ.png]
Duke, Javas official maskot.

What is Java?


Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java is as of 2012 one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users.
The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.


Why use Java?


Because you can write applications that can run on all kinds of systems.

You can write a desktop application that can run on windows, mac, linux and solaris.

Java is used on more than 850 million machines, and you can develop applications for mobile phones, android and much more!


Classes


To declare a class, you do this. The class name is RedHat.


Code:
public class RedHat {

}

Now you have made a class in Java.

inside the class, you can add methods and fields.


Code:
public class RedHat {
  private String name = "redpois0n";
  private int age = 18;
  private boolean male = true;
}

Now we got 3 fields in our RedHat class, called name, age, and male.

Since these fields are private, we cant access them from the outside.


Code:
RedHat hat = new RedHat();
int age = hat.age; //wont work

It wont work since the fields are private, so we need to generate getters.

Getters is a kind of method that will return the field.

So instead of getting the field directly, you call a method that will return it for you.
Code:
public class RedHat {
  private String name = "redpois0n";
  private int age = 18;
  private boolean male = true;

  public String getName() {
  return this.name;
  }

  public int getAge() {
  return this.age;
  }

  public boolean getMale() {
  return this.male;
  }

}

Now, we can access the fields.


Code:
RedHat hat = new RedHat();
int age = hat.getAge(); //will return hat.age

But what if you want to change the fields?


Code:
public class RedHat {
  private String name = "redpois0n";
  private int age = 18;
  private boolean male = true;

  public void setName(String name) {
  this.name = name;
  }

  public void setAge(int age) {
  this.age = age;
  }

  public void setMale(boolean male) {
  this.male = male;
  }

}

Now, you set the private fields as well.
Code:
RedHat hat = new RedHat();
int age = hat.getAge(); //will return hat.age
hat.setAge(age + 10); //will set age 18 + 10
System.out.println(hat.getAge()); //new age


Keywords
Taken from wikipedia.
[Image: GsOyn.png]

[Image: lX2Gu.png]



abstract

The abstract keyword is used to declare a class or method to be abstract. An abstract method has no implementation; all classes containing abstract methods must themselves be abstract, although not all abstract classes have abstract methods. Objects of a class which is abstract cannot be instantiated, but can be extended by other classes. All subclasses of an abstract class must either provide implementations for all abstract methods, or must also be abstract.

assert

The assert keyword, which was added in J2SE 1.4, is used to make an assertion—a statement which the programmer believes is always true at that point in the program. If assertions are enabled when the program is run and it turns out that an assertion is false, an AssertionError is thrown and the program terminates. This keyword is intended to aid in debugging.

boolean

The boolean keyword is used to declare a field that can store a boolean value; that is, either true or false. This keyword is also used to declare that a method returns a value of type boolean.

break

Used to resume program execution at the statement immediately following the current enclosing block or statement. If followed by a label, the program resumes execution at the statement immediately following the enclosing labeled statement or block.

byte

The byte keyword is used to declare a field that can store an 8-bit signed two's complement integer. This keyword is also used to declare that a method returns a value of type byte.

case

The case keyword is used to create individual cases in a switch statement; see switch.

catch

Defines an exception handler—a group of statements that are executed if an exception is thrown in the block defined by a preceding try keyword. The code is executed only if the class of the thrown exception is assignment compatible with the exception class declared by the catch clause.

char

The char keyword is used to declare a field that can store a 16-bit Unicode character. This keyword is also used to declare that a method returns a value of type char.

class

A type that defines the implementation of a particular kind of object. A class definition defines instance and class fields, methods, and inner classes as well as specifying the interfaces the class implements and the immediate superclass of the class. If the superclass is not explicitly specified, the superclass is implicitly Object.

const

Unused, cant be used for anything

Although reserved as a keyword in Java, const is not used and has no function. For defining constants in java, see the 'final' reserved word.

continue

Used to resume program execution at the end of the current loop body. If followed by a label, continue resumes execution at the end of the enclosing labeled loop body.

default

The default can optionally be used in a switch statement to label a block of statements to be executed if no case matches the specified value; see switch.

do

The do keyword is used in conjunction with while to create a do-while loop, which executes a block of statements associated with the loop and then tests a boolean expression associated with the while. If the expression evaluates to true, the block is executed again; this continues until the expression evaluates to false.

double

The double keyword is used to declare a field that can hold a 64-bit double precision IEEE 754 floating-point number. This keyword is also used to declare that a method returns a value of type double.

else

The else keyword is used in conjunction with if to create an if-else statement, which tests a boolean expression; if the expression evaluates to true, the block of statements associated with the if are evaluated; if it evaluates to false, the block of statements associated with the else are evaluated.

enum

A Java keyword used to declare an enumerated type. Enumerations extend the base class Enum.

extends

Used in a class declaration to specify the superclass; used in an interface declaration to specify one or more superinterfaces. Class X extends class Y to add functionality, either by adding fields or methods to class Y, or by overriding methods of class Y. An interface Z extends one or more interfaces by adding methods. Class X is said to be a subclass of class Y; Interface Z is said to be a subinterface of the interfaces it extends.
Also used to specify an upper bound on a type parameter in Generics.

final

Define an entity once that cannot be changed nor derived from later. More specifically: a final class cannot be subclassed, a final method cannot be overridden, and a final variable can occur at most once as a left-hand expression. All methods in a final class are implicitly final.

finally

Used to define a block of statements for a block defined previously by the try keyword. The finally block is executed after execution exits the try block and any associated catch clauses regardless of whether an exception was thrown or caught, or execution left method in the middle of the try or catch blocks using the return keyword.

float

The float keyword is used to declare a field that can hold a 32-bit single precision IEEE 754 floating-point number. This keyword is also used to declare that a method returns a value of type float.

for

The for keyword is used to create a for loop, which specifies a variable initialization, a boolean expression, and an incrementation. The variable initialization is performed first, and then the boolean expression is evaluated. If the expression evaluates to true, the block of statements associated with the loop are executed, and then the incrementation is performed. The boolean expression is then evaluated again; this continues until the expression evaluates to false.
As of J2SE 5.0, the for keyword can also be used to create a so-called "enhanced for loop"[17], which specifies an array or Iterable object; each iteration of the loop executes the associated block of statements using a different element in the array or Iterable.

goto

Unused, cant be used for anything

Although reserved as a keyword in Java, goto is not used and has no function

if

The if keyword is used to create an if statement, which tests a boolean expression; if the expression evaluates to true, the block of statements associated with the if statement is executed. This keyword can also be used to create an if-else statement; see else

implements

Included in a class declaration to specify one or more interfaces that are implemented by the current class. A class inherits the types and abstract methods declared by the interfaces.

import

Used at the beginning of a source file to specify classes or entire Java packages to be referred to later without including their package names in the reference. Since J2SE 5.0, import statements can import static members of a class.

instanceof

A binary operator that takes an object reference as its first operand and a class or interface as its second operand and produces a boolean result. The instanceof operator evaluates to true if and only if the runtime type of the object is assignment compatible with the class or interface.

int

The int keyword is used to declare a field that can hold a 32-bit signed two's complement integer. This keyword is also used to declare that a method returns a value of type int.

interface

Used to declare a special type of class that only contains abstract methods, constant (static final) fields and static interfaces. It can later be implemented by classes that declare the interface with the implements keyword.

long

The long keyword is used to declare a field that can hold a 64-bit signed two's complement integer. This keyword is also used to declare that a method returns a value of type long.

native

Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language.

new

Used to create an instance of a class or array/an object.

package

A group of types. Packages are declared with the package keyword.

private

The private keyword is used in the declaration of a method, field, or inner class; private members can only be accessed by other members of their own class.

protected

The protected keyword is used in the declaration of a method, field, or inner class; protected members can only be accessed by members of their own class, that class's subclasses or classes from the same package.

public

The public keyword is used in the declaration of a class, method, or field; public classes, methods, and fields can be accessed by the members of any class.

return

Used to finish the execution of a method. It can be followed by a value required by the method definition that is returned to the caller.

short

The short keyword is used to declare a field that can hold a 16-bit signed two's complement integer[7][8]. This keyword is also used to declare that a method returns a value of type short.

static

Used to declare a field, method, or inner class as a class field. Classes maintain one copy of class fields regardless of how many instances exist of that class. static also is used to define a method as a class method. Class methods are bound to the class instead of to a specific instance, and can only operate on class fields. (Classes and interfaces declared as static members of another class or interface are actually top-level classes and are not inner classes.)

strictfp

A Java keyword used to restrict the precision and rounding of floating point calculations to ensure portability.

super

Used to access members of a class inherited by the class in which it appears. Allows a subclass to access overridden methods and hidden members of its superclass. The super keyword is also used to forward a call from a constructor to a constructor in the superclass.
Also used to specify a lower bound on a type parameter in Generics.

switch

The switch keyword is used in conjunction with case and default to create a switch statement, which evaluates a variable, matches its value to a specific case, and executes the block of statements associated with that case. If no case matches the value, the optional block labelled by default is executed, if included.

synchronized

Used in the declaration of a method or code block to acquire the mutex lock for an object while the current thread executes the code. For static methods, the object locked is the class' Class. Guarantees that at most one thread at a time operating on the same object executes that code. The mutex lock is automatically released when execution exits the synchronized code. Fields, classes and interfaces cannot be declared as synchronized.

this

Used to represent an instance of the class in which it appears. this can be used to access class members and as a reference to the current instance. The this keyword is also used to forward a call from one constructor in a class to another constructor in the same class.

throw

Causes the declared exception instance to be thrown. This causes execution to continue with the first enclosing exception handler declared by the catch keyword to handle an assignment compatible exception type. If no such exception handler is found in the current method, then the method returns and the process is repeated in the calling method. If no exception handler is found in any method call on the stack, then the exception is passed to the thread's uncaught exception handler.

throws

Used in method declarations to specify which exceptions are not handled within the method but rather passed to the next higher level of the program. All uncaught exceptions in a method that are not instances of RuntimeException must be declared using the throws keyword.

transient

Declares that an instance field is not part of the default serialized form of an object. When an object is serialized, only the values of its non-transient instance fields are included in the default serial representation. When an object is deserialized, transient fields are initialized only to their default value. If the default form is not used, e.g. when a serialPersistentFields table is declared in the class hierarchy, all transient keywords are ignored.

try

Defines a block of statements that have exception handling. If an exception is thrown inside the try block, an optional catch block can handle declared exception types. Also, an optional finally block can be declared that will be executed when execution exits the try block and catch clauses, regardless of whether an exception is thrown or not. A try block must have at least one catch clause or a finally block.

void

The void keyword is used to declare that a method does not return any value.

volatile

Used in field declarations to specify that the variable is modified asynchronously by concurrently running threads. Methods, classes and interfaces thus cannot be declared volatile.

while

The while keyword is used to create a while loop, which tests a boolean expression and executes the block of statements associated with the loop if the expression evaluates to true; this continues until the expression evaluates to false. This keyword can also be used to create a do-while loop; see do.


Reserved words for literal values


false

A boolean literal value, false.

true

A boolean literal value, true.

null

A reference literal value, null is nothing.

Getting started


When you start Java, I would suggest having previous knowledge in a similar language, by that way you will have easier learning.

I had easy time learning Java since I knew basic C#.

You need
  • Java installed
  • JDK (Java Development Kit) installed
  • An IDE (Eclipse)

To install this, a simple google search can guide you there.

Java: - http://www.java.com/getjava/
JDK (Java Development Kit) - http://www.oracle.com/technetwork/java/j...index.html
Eclipse: - http://www.eclipse.org/

Now, you install all of these, of course.

Writing first application


Here you are, if you just started.

[Image: 2Q1lq.png]

You create a new Java Project.

[Image: Dyozj.png]

You open the project in the package explorer, open it, then right click the "src" folder and click "new" then "class".

You create a class like this.

[Image: txr7A.png]

public static void main(String[]) is the main entry point in a java program.

Lets write a hello world program.

[Image: YlzBs.png]

You do like that.

Now we press this button: [Image: Ao1zp.png]

The program should run, as we told it to, and print out "Hello hackforums!" in the console.

[Image: 6PLmz.png]

You just made your first hello world program!

Operators


Commonly used: (by me)

Simple Assignment Operator

= - Simple assignment operator - Used to assign things

Arithmetic Operators

+ - Additive operator (also used for String concatenation)
- - Subtraction operator
* - Multiplication operator
/ - Division operator
% - Remainder operator

Unary Operators

+ - Unary plus operator; indicates positive value (numbers are positive without this, however)
- - Unary minus operator; negates an expression
++ - Increment operator; increments a value by 1
-- - Decrement operator; decrements a value by 1
! - Logical complement operator; inverts the value of a boolean

Equality and Relational Operators

== - Equal to
!= - Not equal to
> - Greater than
>= - Greater than or equal
< - Less than
<= - Less than or equal

Conditional operators

&& - and
|| - or
?: - Ternary (shorthand for if-then-else statement)

Type Comparison Operator

instanceof - Compares an object to a specified type

Rarely used: (by me)

Bitwise and Bit Shift Operators

~ - Unary bitwise complement
<< - Signed left shift
>> - Signed right shift
>>> - Unsigned right shift
& - Bitwise and
^ - Bitwise exclusive or
| - Bitwise inclusive or

More detailed Java tutorials to be posted soon !!!

CREDITS:- Redpois0n (hf)
     

In depth VB.NET guide

The Basics of Visual Basic .NET (VB.NET)
  • Table of Contents
    • Introduction to VB.NET
    • Getting to know your way around the IDE
    • Handling Errors in VB.NET
    • Basic Syntax
    • Various Statements
Visual Basic .NET (VB.NET), is an object-oriented computer programming language that can be viewed as an evolution of the classic Visual Basic (VB), which is implemented on the .NET Framework. Microsoft currently supplies two major implementations of Visual Basic: Microsoft Visual Studio 2010, which is commercial software and Visual Basic Express Edition 2010, which is free of charge.



System Requirements

Software Requirements
  • Visual Studio 2010 can be installed on the following operating systems:
    • Windows XP (x86) with Service Pack 3 - all editions except Starter Edition
    • Windows Vista (x86 & x64) with Service Pack 2 - all editions except Starter Edition
    • Windows 7 (x86 & x64)
    • Windows Server 2003 (x86 & x64) with Service Pack 2
    • Windows Server 2003 R2 (x86 & x64)
    • Windows Server 2008 (x86 & x64) with Service Pack 2
    • Windows Server 2008 R2 (x64)

Hardware Requirements

  • Computer that has a 1.6GHz or faster processor
  • 1 GB (32 Bit) or 2 GB (64 Bit) RAM (Add 512 MB if running in a virtual machine)
  • 3GB of available hard disk space
  • DirectX 9 capable video card running at 1024 x 768 or higher-resolution display
  • DVD-ROM Drive



Downloading an IDE

The first thing we're going to need to do is download an IDE (Integrated Development Environment) for Visual Basic.

There are not that many that I could find except for the one that ICSharpCode has developed and the one that Microsoft provides (recommended).


Namespaces and Classes

Let's think of all these things like a toolbox. Inside this tool box you have all your various tools to fix your problems, in this case, to make your application accomplish what you need it too.

Take a look at this diagram:


[Image: namespacesandclasses.png]

As you can see the namespace is the actual toolbox, which holds your various classes, subs, and functions. (I know everyone is jelly of my mad paint skillz, I offer lessons, of course. ;3)

Namespaces are the actual container, which offers nothing but organization for everything else. While your classes, subs and functions are your actual 'tools' to 'fix' your 'problems'.

Here is an example of a namespace:

Code:
Namespace YourNamespace

End Namespace

That is how you declare a namespace. Pretty simple.

Now we'll get down to the classes. Here is how you declare a class within your namespace:

Code:
Namespace YourNamespace

  <Public/Private Keyword> Class YourClass

  End Class

End Namespace

A class is somewhat like a...mini-namespace I guess you could say, except some classes actually have a purpose and can be used to call other various items.

When you declare a class, unlike a namespace, you will notice in the IDE how it changes to a specific color:

[Image: pcpsXDwBlLbEhfBDGqGD_zps64404d2f.png]

That just makes it easier on the developer to quickly find classes. You can also change the colors of various items by viewing the end of this article where miscellaneous items are classified.

There are 2 different keywords you can use while declaring a class, one is "Public" and the other is "Private". The "Public" keyword allows your class(es) to be called anywhere in your project. There are no limits to where they can be called if it is declared as public. On the other hand, the "Private" keyword makes elements only accessible from within their declaration context. So, if I declare a class in the namespace "YourNamespace" -- I cannot call it from "YourOtherNamespace" if it is declared Private -- but if it is declared Public, I could.




Subs and Functions


Now lets take the previous diagram we used and add in the subs and functions:

[Image: namespacediagramvbnet.png]

You may notice how some of the boxes are bigger than the others, that is because, obviously, some subs and functions are larger than the others (code wise).

Now, you might be asking yourself, "What is the difference between subs and functions?", if you're not, then you just did. ;3

The main difference is Functions, while they don't necessarily have to, usually return a value. Subs are just for carrying out different tasks and they do not, and cannot, return a value.

This is how you declare a Function:

Code:
Namespace YourNamespace

  <Public/Private Keyword> Class YourClass
    <Public/Private Keyword> Function TheFuntionsName(<ByVal/ByRef> SomeArgumentName As <Object/Variable Type>)
  'Do Something
  Return "SomeThing"
    End Function
  End Class

End Namespace

You might've noticed something new in their that we have not gone over yet, that would be the ByVal and ByRef keyword. These keywords are specifically used for declaring arguments in Subs and Functions. The different between the 2 is that ByVal will not allow you to change the value of the argument within the body of the Function while ByRef will.


Getting to know your way around the IDE

The IDE for VB is very big, and if you're just opening it up it might seem like an impossible task to know how to work this giant machine; but let me reassure you that it is not as difficult as it seems.

Go ahead and create a new Windows Form Application and notice how the IDE changes:


Without a project opened 


With a project opened 

[Image: FrqyBWQyMwLWobTHARrb_zpsa6644075.png]

Let's take a look at the most notable changes; these will also be the things you use the most:
Big picture
[Image: changeswhenprojectopened.png]

The toolbox has been populated with all the various components and controls that you can add to your project, the "Properties" box has become visible (pay attention how it changes depending on what you click on, component wise.) and the solution explorer has also become visible.

The Toolbox

The toolbox is what holds all your various components for WFA's (Windows Form Applications). They are all catagorized based on certain things, take a look at this picture:
[Image: lePdXqPstjCnipYApwoH_zps6745f830.png]
  • All Windows Forms
    • This is as straight up as it gets, everything in all the other sub-sections is in this one massive section.
  • Common Controls
    • The things that people use the most have been put under this section. Some things include the: TextBox, RichTextBox, Button, CheckBox, RadioButton, and Label. This is usually the only thing that I keep "opened". Everything else just clutters my space, in my opinion.
  • Reporting
    • Personally, I have never used anything under this section. Then again, I downloaded VB to make l33t ub3r h3ck3r shit so that could be why. Under this category there is only one thing; ReportViewer. Like I said I've never used it before so I myself cannot give any insights to what it might be helpful for.
  • Containers
    • FlowLayoutPanel
      • This control will give you a display like your desktop, literally.
    • GroupBox
      • The GroupBox serves no purpose really except to provide some organization of a mass of various controls. It definitely makes your UI look better if you have a fuck ton of CheckBox's everywhere to just add one of these and place them all in there.
    • Panel
      • The Panel control is somewhat like the GroupBox, except the GroupBox offers the ability to add a caption to the top of it.
    • SplitContainer
      • The SplitContainer is basically 2 Panels but together and separated in the center. You can then use the separator in the center to re-size the control either to the Right or Left by default.
    • TabControl
      • This offers something to where you can add tabs and then organize your controls on the various TabPages that you add to the TabControl. Very helpful for Document editors or large projects.
    • TableLayoutPanel
      • This is the only control that I have not used under this section. Read more about it here.
  • Menus & Toolbars
    • ContextMenuStrip
      • The ContextMenuStrip is something that you can set for specific controls or a mass of controls and it will act as the "Right Click Menu". In other words, when you "Right Click" on the control you set the ContextMenuStrip for it will pop up with all the options that you added to it.
    • MenuStrip
      • The MenuStrip is just like the ContextMenuStrip except the MenuStrip will be docked at the top of your application, and can have multiple "Menus" within this one control.
    • StatusStrip
      • The StatusStrip is docked at the bottom of your application, and only certain controls can be added to it. These include: A mini-progress bar, Label(s), A DropDownMenu (DropDownButton), and a SplitButton.
    • ToolStrip
      • A ToolStrip is somewhat like a MenuStrip except it also supports buttons that can have images as backgrounds instead of text.
    • ToolStripContainer
      • A ToolStripContainer is exactly what is sounds like; a container for ToolStrips.
  • Data
    • Read more about everything under the Data section here.
  • Components
    • Read more about everything under the Components section here.
  • Dialogs
    • ColorDialog
      • The color dialog is a dialog that will be shown when calling ShowDialog and will return the color that the user selected.
    • FolderBrowserDialog
      • The FolderBrowserDialog is a dialog that will be shown when calling ShowDialog, like any other Dialog, and will return a number that corresponds to the Directory they selected. You can then use Environment.GetFolderPath(.SelectedPath) and it will return the absolute address of the Folder the user selected.
    • FontDialog
      • The FontDialog is a dialog, and like every other dialog can be called by using ShowDialog and will return a font that the user selected. You could use this dialog to change the font of a TextBox, for example.
    • OpenFileDialog
      • The OpenFileDialog can be called, like every other dialog, by using ShowDialog. This will return the path of a file that the user selected and you can then use the IO.File.ReadAllText function to get the Text of that file or ReadAllBytes if it is an assembly.
    • SaveFileDialog
      • This will create a new file in the path that the user selected and you can then proceed to use WriteAllText to write text to that file or WriteAllBytes to write bytes to create an assembly.

The Solution Explorer

The Solution Explorer is like a built in Windows Explorer specifically for your project.

There are several different buttons on the solution explorer, let's go over them.
  • The "Home" button. [Image: KdFPcNScATXgRGZPXiUi_zps6e9a841e.png]
    • The "Home" button will take you back to where you were as soon as the Solution Explorer was opened.
  • "Collapse All". [Image: evYhitRipDRWsXyPJCnT_zpsb0e87c7f.png]
    • Collapse all will take everything like this: [Image: ewEZOsotLNmatiiYhGWR_zps05d19ad9.png]
    • And turn it into this: [Image: JlnGsNOWoUWsMnahRpmE_zps8fb1e47e.png]
  • "Properties" (Shortcut: ALT + ENTER) [Image: SytWPStduQMbUgJlfUfc_zps509c7f57.png]
    • This button will jump to the "Properties Box" for the selected component/control.
  • "Show All Files" [Image: jqscFjvmQBsIOWPawxPt_zps4b89bce6.png]
    • This button toggles whether or not to show files that are not part of your project but are in the directory of your project.

The Properties "Box"

The reason "Box" is in quotes is because I couldn't think of something more accurate to call it, lol. Rolleyes

This is what it looks like:
Properties box (Click to View)

This shows you most of the settings applicable to the control/component that you're focused on. Some things are not changeable via the properties box and you must manually set them. I cannot give you any insights to what these are because they vary so heavily based on components/controls.


Handling Errors in VB.NET
Errors are easy to get and sometimes tedious to fix

Errors; they piss you off, they piss ME off. You're eventually going to get that error that you think is going to be impossible to fix. Let me tell you this: You're wrong. VB.NET has a statement called the Try...Catch...Finally statement that is made specifically for error handling. I've devoted this post specifically for Error Handling instead of adding this to the Statements section because I feel as if this is one of the most important statements that you should learn to use.

Let's go over it


Try...Catch...Finally
"Provides a way to handle some or all possible errors that may occur in a given block of code, while still running code."
This is how one of these statements would look:
Try
[ tryStatements ]
[ Catch [ exception [ As type ] ] [ When expression ]
[ catchStatements ] ]
[ Exit Try ]
...
[ Finally
[ finallyStatements ] ]
End Try


The break down
(Courtesy of MSDN)
  • tryStatements
    • This is optional but it's pointless if you do not include these. This is the code where you think an error will occur. There can be multiple statements within for checking.
  • Catch
    • Optional. Multiple Catch blocks permitted. If an exception occurs while processing the Try block, each Catch statement is examined in textual order to determine if it handles the exception. Exception represents the exception that has been thrown.
  • exception
    • Optional. Any variable name. The initial value of exception is the value of the thrown error. Used with Catch to specify the error caught.
  • type
    • Optional. Specifies the type of class filter. If the value of exception is of the type specified by type or of a derived type, the identifier becomes bound to the exception object.
  • When
    • Optional. A Catch statement with a When clause will only catch exceptions when expression evaluates to True. A When clause is only applied after checking the type of the exception, and expression may refer to the identifier representing the exception.
  • expression
    • Optional. Must be implicitly convertible to Boolean. Any expression that describes a generic filter. Typically used to filter by error number. Used with When keyword to specify circumstances under which the error is caught.
  • catchStatements
    • Optional. Statement(s) to handle errors occurring in the associated Try block. Can be a compound statement.
  • ExitTry
    • Optional. Keyword that breaks out of the Try...Catch...Finally structure. Execution resumes with the Finally block if present, otherwise with the code immediately following the End Try statement. Not allowed in Finally blocks.
  • Finally
    • Optional. A Finally block is always executed when execution leaves any part of the Try statement.
  • finallyStatements
    • Optional. Statement(s) that are executed after all other error processing has occurred.
  • End Try
    • Terminates the Try...Catch...Finally structure.


Variables
String, Integers, Booleans and More

Next, we're going to work on all the syntax in VB.NET, building up to creating your first application.

Visual Basic's syntax is created to be more...logical I guess you could say. It could probably be read by anyone with common sense.

Now let's take a look at what we'll use the most...

Variables can be a variety of things. Mainly they're going to be strings, integers, booleans, and declaring objects. (Like WebClients (System.Net namespace) and other things)

Declaring Variables

The following image will show you how to declare variables:


[Image: 7nREJer.gif]

Why there are more data types of variables you can declare for things that suite your need, these are the most common ones and will be the most used. Here is a list of all the different data types:

Data Types 
Boolean - True of False Values

Byte - 8 bit unsigned integer

Char - 16 bit Unicode character

DateTime - Date and time of the current day.

Decimal - Decimal number

Double - 64 bit floating-point number

Int16 - 16 bit signed integer

Int32 - 32 bit signed integer

Int64 - 64 bit signed integer

SByte - 8 bit signed integer

Single - 32 bit floating-point number

UInt16 - 16 bit unsigned integer

UInt32 - 32 bit unsigned integer

UInt64 - 64-bit unsigned integer

using one of these data types:
Dim <LocalName> As [New] <DataType/Object>

Example:
Dim Abc123 As String = "This is an example string. ;)"

Example with the 'New' keyword:
Dim wC As New System.Net.WebClient()

Declaring Variable Arrays

Arrays use indices to stored multiple data types, and let you use a number to tell them apart because they will use the same name. It is basically like declaring, for instance, 5 strings in one. This is how you declare an array for a string:

Code:
Dim str As String() ' notice the () at the end. That is how you know if it is an array.

str = {"One string", "Two strings", "Etc."} ' These strings are enclosed in brackets and separated by commas.

'This is how you call "One string":
MsgBox(str(0)) ' would output in a message box: "One string"

'this is how you call "Two strings":
MsgBox(str(1)) ' would output in a message box: "Two strings"

'This is how you call "Etc.":
MsgBox(str(2)) ' would output in a message box: "Etc."

See how that works? Take a look at this GIF if you're having some trouble...


[Image: M8Nhy5c.gif]



Declaring Objects

Objects can be a wide range of things. In this example we're going to be using a WebClient. A WebClient "provides common methods for sending data to and receiving data from a resource identified by a
URI." - MSDN

While a WebClient has to be declared like this:
Dim wc As New WebClient()

Some things like the XMLReader and XMLWriter in the System.Xml namespace have to be declared like this:
Dim xml As XMLWriter = XMLWriter.Create(Arguments+)
or
Using xml As XMLWriter = XMLWriter.Create(Arguments+)
You can see all the arguments that something requires by going to MSDN.
Using Google Dorks will limit the results, example: some function site:msdn.microsoft.com

Anyways, continuing with the WebClient example.
Once you have declared your WebClient():

Code:
Namespace YourNamespace

  <Public/Private Keyword> Class YourClass
    Dim wc As New WebClient() 'now it is declared
  End Class

End Namespace

Let's go over some of the various and most commonly used functions for a WebClient()

DownloadFile(Uri, String) -- Downloads a file from a Uri and saves it to the file path aka the second argument.
DownloadString(Uri) -- Downloads a string from a Uri and then returns that string.

Now to call these functions we would use the name of the Object we created that is the WebClient, in this case, wc and then add the function we want after that; i.e.:
wc.DownloadFile("http://www.somesite.com/file.exe", "C:\Users\Shit\Fuck\File.exe")

For the other one, since it returns a value, we would have to declare a string in order to "capture" that value. Like so:
Dim str As String = wc.DownloadString("http://www.somesite.com/file.txt")

Now the String that we declared will be the contents of the Text File that we downloaded.


Statements

If...Then...Else - Do { While | Until } - For Each...Next - For...Next
If...Then...Else
"Conditionally executes a group of statements, depending on the value of an expression."

Now let us say that you have more than one variable (Which 99.99 % of the time, you are going to), and you want to see what that variable is equal to or maybe compare it to another variable. This would be accomplished by using an If statement. First let's declare our variables...


Code:
Dim str As String = "123"
Dim anotherStr As String = "1234"

Next let's have a brief overview of the If statement.

This is how it will look (without all the brackets):

Code:
If condition [ Then ]
   [ statements  ]
[ ElseIf elseifcondition [ Then ]
   [ elseifstatements ] ]
[ Else
   [ elsestatements ] ]
End If

As you can tell the If statement contains 2 other things within it. These are Else and ElseIf, then of course you have the End If which ends the If statement.

This is how you would compare the 2 previous variables that we declared:

Code:
If str = anotherStr Then
MsgBox("Holy shit! They're the same!")
Else
Application.Exit()
End If

In this case since str = 123 and anoterStr = 1234 it would not pop up the MsgBox, it would close the application because the strings are not the same.

Now, in this case, we really only need Else, but say that you wanted to see if str = "abc" and if it did it would execute something instead of Application.Exit()...that is when ElseIf comes into play. This is how we could to that:

Code:
If str = anotherStr Then
MsgBox("Holy shit! They're the same!")
ElseIf str = "abc" Then
MsgBox("OMFG str = abc.")
Else
Application.Exit()
End If

here is the thing when using If statements though. If the initial check is true it will not check the ElseIf or execute the Else.




Do { While | Until }...
"Repeats a block of statements while a Boolean condition is True or until the condition becomes True."

This is how one of these statements would look:
Do { While | Until } condition
[ statements ]
[ Exit Do ]
[ statements ]
Loop


-or-

Do
[ statements ]
[ Exit Do ]
[ statements ]
Loop { While | Until } condition


The break down

  • While
    • This is required unless you use Until. While will repeat the Loop until the condition that you supplied becomes False.
  • Until
    • This is required unless you use While. Until will repeat the Loop until the condition that you supplied becomes True.
  • condition
    • This is an optional Boolean variable that will be used to evaluate the expression for True or False.
  • statements
    • This is also optional and would be one or more statements that would repeat while or until the condition becomes True or False.

Optional Remarks for the Do { Until | While } statement
Courtesy or MSDN.
The Exit Do statement transfers control immediately to the statement following the Loop statement. Any number of Exit Do statements can be placed anywhere in the Do loop. Exit Do is often used after evaluating some condition, for example with If...Then...Else.



For Each...Next
"Repeats a group of statements for each element in a collection."

This is how one of these statements would look:
For Each element [ As datatype ] In group
[ statements ]
[ Exit For ]
[ statements ]
Next [ element ]


The break down
  • element
    • Any type of variable that is used to iterate, or, loop through the elements of the collection that you supplied. Please note: the datatype of element must be an element that the data type of the elements in the group that you supplied can be converted too. Basically you cannot use a String for something that returns an Integer.
  • datatype
    • Required if element is not declared. If element is declared you cannot re-declare it using the As clause.
  • group
    • This is required and should be an Object variable that must refer to an object collection or an array.
  • statements
    • You can optionally add in various statements that will be executed while the loop is in progress. This will be executed for each element in the group.

Optional remarks for For Each...Next
Courtesy of MSDN
If element has not been declared outside this loop, you can declare it within the For Each statement. In this case, the scope of element is the body of the loop. However, you cannot declare element both outside and inside the loop.

The For Each...Next loop is entered if there is at least one element in group. Once the loop has been entered, the statements are executed for the first element in group; if there are more element(s) in group, the statements in the loop continue to execute for each element (That's why this os called a For Each loop.). When there are no more element(s), the loop is terminated and execution continues with the statement following the Next statement.

Any number of Exit For statements may be placed anywhere in the loop as an alternative way to exit. Exit For is often used after evaluating some condition, for example with an If...Then...Else statement, and transfers control to the statement immediately following Next.

You can nest For Each...Next loops by placing one loop within another. Each loop must have a unique element variable.



For...Next
"Repeats a group of statements a specified number of times."

This is how one of these statements would look:
For counter [ As datatype ] = start To end [ Step step ]
[ statements ]
[ Exit For ]
[ statements ]
Next [ counter ]


The break down
  • counter
    • This expression is required. The counter variable has to be a numeric datatype that supports the greater-than or equal to (>=), less-than or equal to (<=), and the addition (+) operators.
  • datatype
    • This is required if counter is not already declared. This expression is the datatype of counter. (Ex: Integer) If datatype is already declared then you cannot use the As clause to re-declare it.
  • start
    • This expression is required and is the initial value of counter. The start expression is usually an Integer but can be any data type as long as it widens to the type of counter.
  • end
    • This expression is required and is the final value of counter. The end expression is usually an Integer but can be any data type as long as it widens to the type of counter.
  • step
    • This expression is optional. step would be the value to increase the counter by each time it passes through the loop. The step expression is usually an Integer but can be any data type as long as it widens to the type of counter. If step's value is not declared; the default is one (1).
  • statements
    • You can optionally add in various statements that will be executed while the loop is in progress. These statements will be executed a specific number of times.

Optional remarks for the For...Next statement
Courtesy of MSDN
If counter has not been declared outside this loop, you can declare it within the For statement. In this case, the scope of counter is the body of the loop. However, you cannot declare counter both outside and inside the loop.

The step argument can be either positive or negative. The value of the step argument determines loop processing as follows:
  • Step value
    • Positive (1 and up) or Zero (0)
      • Loop executes if counter <= end.
    • Negative (0 and down)
      • Loop executes if counter >= end
CREDITS:-  SomeWhiteGuy (hackforums) !!