Parag’s Den

Dedicated to my adored friends…..

04- Basics of Programming

Posted by paragdongre on June 4, 2008

 

Variables

Variables are basically elements in a computer program that can take any assigned value. They can change from time to time, depending on the programmer and the user. For example, if a computer program requires a user to enter his or her name then the entity “name” will change from time to time depending on the user. The element “name” is considered a variable and can take on any value assigned to it. You will be using a lot of variables in your programming.

Data Types

Any kind of variable or element can take on a data type. There are several data types in Visual Basic. To name the most popular and the most useful are the following.

  1. String – this data type is made up of empty text, a single letter or several letters, or a group of words.
  2. Boolean – this data type is either True or False, or 1 or 0 representing the former and the latter, respectively.
  3. Byte – this data type can take on values from 0 to 255
  4. Integer – this data type can take on whole number values from -32,768 to 32,767
  5. Long – this data type can take on whole number values from -2,147,483,648 to 2,147,483,647
  6. Single – this data type can take on floating point numbers or numbers with decimals from -3.402823E38 to – 1.401298E(-45) and from 1.401298E(-45) to 3.402823E38
  7. Double – this data type can take on floating point numbers or numbers with decimals from – 1.79769313486231E308 to – 4.94065645841247E(–324) and from 4.94065645841247E(–324) to 1.79769313486231E308
  8. Variant – this data type can take on any kind of value. Use this data type sparingly because it takes up more than twice the memory of the other data types.

Declaring Variables

If you are ready to declare a variable in a program then you should use the following code:

 Dim X As Integer

Once a variable is declared in a program, you or the user can utilize it appropriately.

Memory Allocation for the Variables

Variables that have more complex data types take up more memory on the computer. Using too much memory can slow down a program or in some cases, may cause a computer to hang. Use your variables wisely and declare them appropriately. For example, if you have a variable that states the number of points of a basketball player in a game then it would be wise to declare “player_points” as byte instead of integer. No basketball player in history has scored more than 255 points in a single game and there is no such thing as a negative basketball point.

 

Operators

Operators are the basic way of manipulating data. The following operators are the most common operators that you will use in programming.

The “+” operator is used if you want to add elements together.

The “-” operator is used if you want to subtract one element from the other. The “-” operator is also used as a negative sign for negative values.

The “*” operator is used for multiplying elements.

The “/” operator is used if you want to divide an element with another element.

The “=” sign denotes that the values on the left side of the “=” sign are equal to the values on the right side.

A basic equation in a program may look like the code below.

 3 + x = 4<
 MsgBox (x) 

If this program is run, a message box will appear on the screen indicating the correct value of x, which is 1.

Writing and Running the Code

Interacting with the User

The intermediary between you, the programmer, and the users out there is the user form. You have learned how to put the textbox and the command button in the previous chapter. This time, you are going to use it. Make a user form with basic textboxes, labels, and a command button similar to the one below.

 

Writing the Code

Simply double click any element on your user form to begin writing code. To start off, double click “Button1” and see a code screen come up. When you type in the code for your program on this screen, make sure that you are referring to the right elements and variables all the time. You do not want to end up jumbling your data. If you are referring to data in Textbox1 then make sure that you don’t have the data of Textbox3 in mind. Once you get all things organized, your code may look like the one below.

Public Class Form1
 private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Button1.Click

 TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

 End Sub
End Class

 

Visual Basic is very user friendly. As you can see, simply double clicking a feature on your user form will automatically insert code. In the code above, take note that the “Val()” code is used to differentiate text from numerical value. Try removing the Val() code and see what happens to the result. You will learn little tidbits of coding as you go along this tutorial so pay attention and absorb all this knowledge.

Running the Program

Once you have the code in place, press F5 or the “play” button on the task bar. You will enter “debug” mode. Test your program and see if it works. If you want to exit debug mode, simply press the “X” button on the upper right corner of the user form or the “stop” button on the task bar.

 

Posted in - VB.Net | Leave a Comment »

05- Strings

Posted by paragdongre on June 4, 2008

 

Text Variables

String variables are an entirely different form of variables. As you may have noticed, all the other variables that were mentioned in the previous chapter have something to do with numbers. String variables deal with text. When you deal with text variables, the commands and the methods associated with them are entirely different. For example, when was the last time that you have heard someone multiply letters? What is the result when you multiply the letter “k” with the letter “n” ? When you work with text variables or string variables, make sure that you do not confuse the numerical manipulation commands with the string or textual manipulation commands.

Declaring the Text Variable or the String Variable

Simply type in the code below to declare a string variable in your program.

 

Dim Jordan as String

 

OR

 

Dim [name of variable] as String

 

Blanks

Sometimes you will encounter blanks with text variables. For example, if a user enters the name ” Jordan” instead of “Jordan,” there will be a space or a blank in front of it. If you want to rid the blanks at the start and at the end of text entered by the user then you can use the trim method. Simply use the code as illustrated below to trim any string variables.

 
        Dim Name As String
 
        Name = Trim(TextBox1.Text)
 
        MsgBox (Name)
               

As you can see, simply enter the text in the Trim() function and the spaces at the start and at the end of the text variable will be gone.

Note: Sometimes users will forget to put an entry in a textbox if you ask them to. In order to recognize blanks, simply use “”. Note that ” ” is different from “” because the former has a space bar entry while the latter has nothing in it. Visual Basic .NET recognizes the difference between the two.

String Position

With VB .NET, you can locate a string within a string. The command used to identify a string within a string is the InStr() command. See the code below and see how it works.

 
        Dim Result As Integer
 
        Result = InStr("Display", "p")
 
        MsgBox(Result)
 

The result returns a value of 4 because “p” is the fourth occurrence on the string. Try changing “p” to “isp” and see what happens. The general structure of the InStr() command is shown below.

 
Instr("[string to look at]","[string to be look for]")

 

Equal Command with Text

If you want text to be represented within a variable then you can use the equals command. See the code below and learn how the equals command is used.

 
        Dim Represent As String
 
        Represent = "This is the result."
 
        MsgBox(Represent)
               

The main structure when using the equals command is as follows.

 
[variable] = "[text]"
 

The variable will then obtain the value of the text.

Working with Text

Joining Text

Aside from using the “=” sign from numerical values, you can also use the “+” sign too. The “+” sign is used to join text together or to concatenate them. If you want to join text together, simply use the “+” sign as seen below.

 
Dim Result As String
 
Result = "Sun" + "day"
 
MsgBox(Result)
               

The result in the message box is the word “Sunday”. Try joining different kinds of texts together. The basic structure for joining text is as follows.

 [first string] + [second string] 

Replacing Text

If you want to replace a certain string or substring then you can use the Replace() command. See the code below and learn how it is used.

 
Dim Represent As String
 
Represent = "Display".Replace("Display", "Screen")
 
MsgBox(Represent)
 

The entire word “Display” is replaced with the word “Screen”. Try changing Replace(“Display”, “Screen”) with Replace(“ispl”,””) and see what happens. The general structure of the Replace command is as follows.

"[string to be looked at]".Replace("[string to be replaced]","[string to replace it]")
 

Inserting Text

If you wish to insert a string of text into an existing string then you can use the Insert() command. See the code below and learn how it is used.

 
        Dim Represent As String
 
        Represent = "Day".Insert(1, "ispl")
 
        MsgBox(Represent)
 

The result that is displayed in the message box is “Display”. Note that the first character in the String is “D” and that is why the “ispl” string was inserted after the character “D”. Try changing Insert(1, “ispl”) to Insert(2, “ispl”) and see what happens. The general structure of the Insert command is as follows.

“[string to be looked at]”.Insert([nth character where string will be inserted], “[string to be inserted]”)

Posted in - VB.Net | Leave a Comment »

06- Conditionl Logic

Posted by paragdongre on June 4, 2008

Conditional Operators

Operators that describe or state a relationship on one side of an expression with the other side of an expression is called a relational or conditional operator. The “=” sign is an operator that states that the values on the left side of the expression is equal to the right side of the expression, thus making it an equation. There are many other conditional operators that you can use in Visual Basic. They are the following.

  • The “<” sign is used to describe an expression where the left side is “less than” the right side.
  • The “>” sign is used to describe an expression where the left side is “greater than” the right side.
  • The “<=” sign is used to describe an expression where the left side is “less than OR equal to” the right side.
  • The “>=” sign is used to describe an expression where the left side is “greater than OR equal to” the right side.
  • The “<>” sign is used to describe an expression where the left side is “not equal to” the right side.

 

Combining Conditional Operators

You can combine the use of conditional operators using the following commands.

The “AND” command combines two conditional operators together. See the code below for an example.

 If x > 5 and y < 3 then z = x – y

The “OR” command selects which one of the two conditional operators are satisfied or dissatisfied. See the code below for an example.

 If x < 5 or y > 6 then z = x + y

 

If – Then

The If-Then statement is used to execute commands given that a set of conditions are satisfied. The basic structure of an If-Then statement is like the one below.

If x < 4 then
 x = x + 1
End If

OR

If [condition] then 
 [command lines]
End If

You can also put additional commands if a condition does NOT hold. You can use the “Else” command to do this. An example of how this is used is shown below.

If x < 4 then
 z = x + 3
Else
 z = x + 9
End If

OR

If [condition] then
 [command lines]
Else
 [command lines]
End If

 

Select Case

The Select Case statements are similar to the If-Then statements. The Select Case statements are used for executing different command lines in several different circumstances. For example, you can run a specific set of commands in scenario one, a specific set of commands in scenario two, and another set of commands in scenario three. Look at the code below and see how the Select Case logic works.

Sub ()

        Dim x As Integer

        Dim result As String

 

        x = 0

        result = “no value”

 

        Select Case x

            Case Is < 0

                result = “x is a negative integer”

            Case Is = 0

                result = “x is neither a positive nor a negative integer”

            Case Is > 0

                result = “x is a positive integer”

        End Select

 

        MsgBox(result)

              

End Sub

In the code above, you can see that the value for x can have three possible outcomes in the message box. Try changing the values of x to -4 and then to 9.

The basic structure of a Select Case code is as follows

        
        Select Case [variable]
               Case [1]
                       [command lines]
               Case [2]
                       [command lines]
               .
               .
               .
               Case [N]
                       [command lines]
        End Select

 

Conditional Logic and User Form

Make a new user form and arrange it as seen below.

You can toggle the starting user form of your application by selecting “My Project” on the Solution Explorer window and then choose “Startup form.”

Double click the button in the middle of your new user form and then write code that will identify if x is a positive, a negative, or neither a positive nor a negative integer. Hint: Review the code awhile ago and infuse it to the user form.

The code for identifying if x is a positive or a negative integer may look similar to the code below.

 
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim x As Integer
        Dim result As String

        x = TextBox1.Text

        Select Case x
            Case Is < 0
                result = “Negative”
            Case Is = 0
                result = “Neither”
            Case Is > 0
                result = “Positive”
        End Select

        TextBox2.Text = result

  End Sub

 

Posted in - VB.Net | Leave a Comment »

07- Loops

Posted by paragdongre on June 4, 2008

For Loop

Loops

Count the number of cups you need to fill a pitcher. This number is feasible and may be programmed on a computer as seen below.

 
        cups = 0
        ‘pitcher is now empty.’
        cups = cups + 1
        cups = cups + 1
        cups = cups + .5
        ‘pitcher is now full.’
        msgbox(cups)

In the code above, you will notice that you can actually count the cups one by one. You will know when the pitcher is empty and you will know when the pitcher is full. In some cases, counting things one by one isn’t actually practical anymore. For instance, what if you were asked to count the number of cups needed to fill a swimming pool? Does this sound fun to you? If you are really bored and have nothing to do with your life then you might as well count the number of cups one by one. If you are knowledgeable with loops then you can let the computer do the counting.

For

The For Loop is called the For Loop because it loops “for every number.” In the code below, you will see that the For Loop adds “for every number.”

        
        counter = 0
        sum = 0
        for counter = 1 to 50
          sum = sum + counter
        next counter
        msgbox(sum)

If you loop the code in your head, it would go like 1 + 2 + 3 + 4 + … … + 49 + 50 = sum. “For every” number, the sum is incremented.

The For Loop takes on the structure below.

        
        For [variable] = [1 to N]
         [command lines]
        next [variable]

 

Do Loops

Do

The Do Loop is called the Do Loop because it “does commands” under certain conditions. There are two types of the Do Loop.

Do While

The Do While Loop does commands while a certain condition holds. See the code below for an example of the Do While Loop

 
 Do while x < 100
  x = x + 1
 Loop
 Msgbox (x)

You can also put the While condition after the Loop command. See the code below for an example.

        
 Do
  x = x + 1
 Loop While x < 100
 Msgbox (x)

If the while is put at the Do line then it will check the condition before it executes the commands. If the while is put at the Loop line then it will execute the commands first before checking the condition. The program will loop based on the conditions given.

The Do While Loop takes on the basic structures below.

        
 Do While [condition}
  [command lines]
 Loop

OR

        
 Do
  [command lines]
 Loop While [condition]

Do Until

The Do Until Loop is called a Do Until Loop because it runs commands until a certain condition is satisfied. Check out the code below for an example.

        
 Do until x = 7
  x = x + 1
 Loop
 Msgbox (x)

Like the Do While Loop, you can also put the until command on the Loop line just like the code below.

        
 Do
  x = x + 2
 Loop Until x = 12
 Msgbox (x)

If the Until is put on the Do line then the computer will check the condition before it performs the commands while if the Until is put on the Loop line then the computer will execute the commands first before checking the conditions.

The Do Until Loop takes on the structures below.

        
 Do Until [condition]
  [command lines]
 Loop

OR

        
 Do
  [command lines]
 Loop Until [condition]

 

Loops and User Forms

Awhile ago, a question was posed if it was possible to count the number of cups to fill a swimming pool. Now that you are equipped with the knowledge of loops, try making a program that can calculate the number of cups needed to fill a swimming pool.

 

You can make a program that can calculate this number without using loops but use loops now for exercise purposes. You will benefit from this later on.

Your code may look something like the one below.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        

 

 ‘one liter is equivalent to .001 cubic meters OR m^3        

‘one cup is equivalent to approximately 230 milliliters OR .00023 m^3         

 

Dim Depth As Double        

Dim Length As Double        

Dim Width As Double         

Depth = TextBox1.Text        

Length = TextBox2.Text       

 Width = TextBox3.Text         

Dim Volume As Double         

Volume = Depth * Length * Width         

Dim Cups As Double        

Dim Counter As Double          

Counter = 0        

Cups = 0         

Do Until Counter > Volume           

  Cups = Cups + 1            

Counter = Counter + 0.00023         

Loop         

Counter = Counter – 0.00023        

Cups = Cups + (Volume – Counter) / 0.00023         

TextBox4.Text = Cups     

End Sub 

Posted in - VB.Net | Leave a Comment »

08- Forms(Advanced)

Posted by paragdongre on June 4, 2008

Learn more tools available in User Form

There are several tools at your disposal on the Visual Basic Toolbox. Listed below are some of the most basic tools aside from the already mentioned label, textbox, and button.
Check out the toolbox and feel free to modify any of your user forms.
Checkbox
Enables the user to select or clear the associated component.
Checked Listbox
Displays a list of items with a check box on the left of each item.
Combobox
Displays an editable textbox with a drop down list of permissible values.
DateTimePicker
Enables the user to pick a date and time and to display the date and time in a specified format.
LinkLabel
Displays a label control that supports the hyperlink capability.
Listbox
Displays a list where the user can select items.
Listview
Displays a list of items in one of five different views.
Masked Textbox
Uses a mask to distinguish between proper and improper user input.
Month Calendar
Displays a monthly calendar wherein the user can select a date.
Notify Icon
Displays an icon in the notification area, on the right side of the windows taskbar.
Numeric Up Down
Specifies support for transacted initialization.
Picture Box
Displays a picture.
Progress Bar
Displays the progress of an operation to a user.
Radio Button
Enables the user to select one option among other radio buttons.
Rich Textbox
Provides the user with advanced text entry.
Tool Tip
Displays information when the user moves the pointer over a control.
Tree View
Displays a hierarchical view of labeled items to the user.
Web Browser
Enables the user to browse the web through a user form.
Aside from the aforementioned tools, feel free to use the other more advanced tools on your toolbox.

Posted in - VB.Net | Leave a Comment »

09- Database

Posted by paragdongre on June 4, 2008

Download a Sample Database from the Microsoft Site

Start this chapter by downloading a sample Database from the Microsoft Site. Enter this URL on your address bar and begin downloading. http://www.microsoft.com/downloads/details.aspx?familyid=C6661372-8DBE-422B-8676-C632D66C529C&displaylang=en . Make sure that you remember where you put the file because you will be specifying the directory later on. Save any previous work you have done on the Visual Basic Application and then create a new project.

Adding a Data Source

The first step in connecting to a database is by identifying the source. Go to the Data Sources tab on the upper right side of the Visual Basic screen and then Add a New Data Source.

 

Select “Database” and then “New Connection…”

Select Data Source and then set it to “Microsoft Access Database File…”

 

The database file name is “Nwind.mdb”. You should know where you saved this *.mdb file when you downloaded it earlier.

Click OK and proceed with adding the data source.

Once you are done, you will see the database for Northwind traders as shown below.

Posted in - VB.Net | Leave a Comment »

10 – Assignments

Posted by paragdongre on June 4, 2008

You have learned many things throughout this tutorial. Now is the time for you to put your skills to the test. This chapter will give you a sample application and several problems to work on. The first problem has a sample application answer while the remaining problems are for you to solve yourself. Remember that there are several ways to solve a problem. Do not worry if your application is not the same as the sample application. As long as it works properly, you are good to go. Good luck!

Make a Calculator that converts Celsius to Fahrenheit and vice versa

Sample User Form is shown below

 

Sample Code is shown below

 

Public Class Form1

    Dim C As Single
    Dim F As Single

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        C = TextBox1.Text

        F = (9 / 5) * C + 32

        TextBox2.Text = F

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        F = TextBox1.Text

        C = (5 / 9) * (F – 32)

        TextBox2.Text = C

    End Sub

End Class

Posted in - VB.Net | Leave a Comment »

TicTac 3D

Posted by paragdongre on November 13, 2007

Hi Friends!
Simply copy this javascript code in notepad and save it as “.HTML” file format. Also download the images by clicking link below -> Tictac-3d.zip(Click to download)

[Note: Save the “.html”  file in downloaded folder i.e. tictac-3d. Plz dont make any type of updation in the code before copying it.]
—————————————————————————————–

 Javascript Code->

<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin
var i, j, k, RotAng, XMouseOver, YMouseOver, LastEvent, IsOver=true, IsStart0;
var Max, NDraw, Start, I_Sel, J_Sel, Start0;
var NeedBallDown, MoveCount, MaxMoveCount;
IsPlayer = new Array(2);
Level = new Array(2); 
Fld = new Array(4);
for (i=0; i<4; i++)
  Fld[i] = new Array(4);
for (i=0; i<4; i++)
{ for (j=0; j<4; j++)
    Fld[i][j] = new Array(4); 
}
ScreenFld = new Array(4);
for (i=0; i<4; i++)
  ScreenFld[i] = new Array(4);
for (i=0; i<4; i++)
{ for (j=0; j<4; j++)
    ScreenFld[i][j] = new Array(2); 
}
FldCount = new Array(4);
for (i=0; i<4; i++)
  FldCount[i] = new Array(4);
Value = new Array(4);
for (i=0; i<4; i++)
  Value[i] = new Array(4);
History = new Array(64);
for (i=0; i<64; i++)
  History[i] = new Array(2);
Pic= new Array(4);
Pic[0] = new Image(); Pic[0].src=”tt3d_0.gif” mce_src=”tt3d_0.gif”;
Pic[1] = new Image(); Pic[1].src=”tt3dred.gif” mce_src=”tt3dred.gif”;
Pic[2] = new Image(); Pic[2].src=”tt3d_1.gif” mce_src=”tt3d_1.gif”;
Pic[3] = new Image(); Pic[3].src=”tt3dblue.gif” mce_src=”tt3dblue.gif”;

IsStart0=true;
IsPlayer[0]=true;
IsPlayer[1]=false;
Level[0]=2;
Level[1]=3;

function Init()
{ var ii, jj, kk;
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { for (kk=0; kk<4; kk++)
        Fld[ii][jj][kk]=0;
      FldCount[ii][jj]=0;
    }
  }
  if (IsStart0) Start0=true;
  else Start0=false;
  LastEvent=””;
  NeedBallDown=0;
  I_Sel=-1; J_Sel=-1;
  MoveCount=0;
  MaxMoveCount=0;
  RotAng=0;
  XMouseOver=-1;
  YMouseOver=-1;
  RefreshScreen();
  IsOver=false;
}

function SetOption(nn, mm)
{ if (nn<2)
  { if (mm==0)
      IsPlayer[nn]=true;
    else
      IsPlayer[nn]=false;
  }
  else IsStart0=mm;
}

function SetLevel(nn, mm)
{ Level[nn]=mm;
}

function Timer()
{ if (IsOver) return;
  if (NeedBallDown==0)
  { if ((((MoveCount+Start0)%2==1)&&(IsPlayer[0]))||
        (((MoveCount+Start0)%2==0)&&(IsPlayer[1])));
    else
    { if (LastEvent==””) GetBestMove(((MoveCount+1+Start0)%2)*2-1);
      if (LastEvent==”TurnLeft”) { TurnLeft(); LastEvent=””; }
      if (LastEvent==”TurnRight”) { TurnRight(); LastEvent=””; }
      if (LastEvent==”Back”) { Back(); LastEvent=””; }
      if (LastEvent==”Replay”) { Replay(); LastEvent=””; }       
    }
  }
  if (NeedBallDown>0)
  { if (Fld[I_Sel][J_Sel][NeedBallDown-1]==0)
    { if (NeedBallDown<4)
        window.document.images[13*(YMouseOver+3-NeedBallDown)+XMouseOver].src = Pic[2].src;
      if ((MoveCount+Start0)%2==1)
        window.document.images[13*(YMouseOver+4-NeedBallDown)+XMouseOver].src = Pic[1].src;
      else
        window.document.images[13*(YMouseOver+4-NeedBallDown)+XMouseOver].src = Pic[3].src;
    }
    if (NeedBallDown>1)
    { if (Fld[I_Sel][J_Sel][NeedBallDown-2]!=0)
        NeedBallDown=1;
    }
    if (NeedBallDown==1)
    { window.document.OptionsForm.Moves.value=MoveCount+1;
      MakeMove();
    }
    NeedBallDown–;
  }
}

function TurnLeft()
{ if (NeedBallDown>0) { LastEvent=”TurnLeft”; return; }
  RotAng–;
  if (RotAng<0) RotAng=7;
  RefreshScreen();
}

function TurnRight()
{ if (NeedBallDown>0) { LastEvent=”TurnRight”; return; }
  RotAng++;
  if (RotAng>7) RotAng=0;
  RefreshScreen();
}

function Back()
{ if (NeedBallDown>0) { LastEvent=”Back”; return; }
  if (MoveCount>0)
  { IsOver=false;
    MoveCount–;
    var ii=History[MoveCount][0];
    var jj=History[MoveCount][1];
    var kk=–FldCount[ii][jj];
    Fld[ii][jj][kk]=0;
    window.document.OptionsForm.Moves.value=MoveCount;
    RefreshPic(ii, jj, kk);
  }
}

function Replay()
{ if (NeedBallDown>0) { LastEvent=”Replay”; return; }
  if (MoveCount<MaxMoveCount)
  { I_Sel=History[MoveCount][0];
    J_Sel=History[MoveCount][1];
    window.document.OptionsForm.Moves.value=MoveCount+1;
    MakeMove();     
    RefreshPic(I_Sel, J_Sel, FldCount[I_Sel][J_Sel]-1);
  }
}

function MakeMove()
{ var ccol, kk;
  ccol=((MoveCount+1+Start0)%2)*2-1;
  kk=FldCount[I_Sel][J_Sel]++;
  Fld[I_Sel][J_Sel][kk]=ccol;
  if (History[MoveCount][0]!=I_Sel)
  { History[MoveCount][0]=I_Sel;
    MaxMoveCount=MoveCount+1;
  }
  if (History[MoveCount][1]!=J_Sel)
  { History[MoveCount][1]=J_Sel;
    MaxMoveCount=MoveCount+1;
  }
  MoveCount++;
  if (MaxMoveCount<MoveCount)
    MaxMoveCount=MoveCount;
  IsOver=IsWinning(I_Sel, J_Sel, kk, ccol);
  if (IsOver)
  { if (ccol<0) alert(“Red has won !”);
    else alert(“Blue has won !”);
  }
  else
  { if (MoveCount==64)
    { IsOver=true;
      alert(“Draw !”);
    }
  }
}

function GetBestMove(theCol)
{ var ii, jj, kk, zz, vv, vvbest, nn, cc=theCol;
  var iiw,jjw,kkw,wwcount;
  var LLevel=Level[(MoveCount+1+Start0)%2];
  I_Sel=-1; J_Sel=-1;
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { if ((kk=FldCount[ii][jj])<4)
      { Fld[ii][jj][kk]=cc;
        if (IsWinning(ii, jj, kk, cc))
        { Fld[ii][jj][kk]=0;
          Select(ii, jj);
          return;
        }
        Fld[ii][jj][kk]=0;
      }
    }
  }
  nn=0;
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { Value[ii][jj]=0;
      if ((kk=FldCount[ii][jj])<4)
      { nn++;
        Fld[ii][jj][kk]=-cc;
        if (IsWinning(ii, jj, kk, -cc))
        { Fld[ii][jj][kk]=0;
          Select(ii, jj);
          return;
        }
        Fld[ii][jj][kk]=0;
      }
    }
  }
  if (LLevel>2)
  { for (ii=0; ii<4; ii++)
    { for (jj=0; jj<4; jj++)
      { if ((kk=FldCount[ii][jj])<4)
        { wwcount=0;
          Fld[ii][jj][kk]=cc;
          if (kk<3)
          { if ((wwcount=CanWin(ii,jj,kk+1,cc))==2)
            { Fld[ii][jj][kk]=0;
              Select(ii, jj);
              return;
            }
          }
          if (wwcount>=0)
          { for (iiw=0; iiw<4; iiw++)    
            { for (jjw=0; jjw<4; jjw++)
              { if ((kkw=FldCount[iiw][jjw])<4)
                { if (!((ii==iiw)&&(jj==jjw)))
                  { Fld[iiw][jjw][kkw]=cc;
                    if (IsWinning(iiw, jjw, kkw, cc))
                      wwcount++;
                    Fld[iiw][jjw][kkw]=0;
                    if (wwcount>1)
                    { Fld[ii][jj][kk]=0;
                      Select(ii, jj);
                      return;
                    }
                  }
                }
              }
            }
          }
          Fld[ii][jj][kk]=0;
        }
      }
    }
  }
  if (LLevel>3)
  { for (ii=0; ii<4; ii++)
    { for (jj=0; jj<4; jj++)
      { if ((kk=FldCount[ii][jj])<4)
        { vv=0;
          Fld[ii][jj][kk]=cc;
          if (kk<3)
          { Fld[ii][jj][kk+1]=-cc;
            if (IsWinning(ii, jj, kk+1, -cc))
              vv=-1;
            Fld[ii][jj][kk+1]=0;
          }
          if (vv==0)
          { Fld[ii][jj][kk]=-cc;
            if(kk<3)
            { Fld[ii][jj][kk+1]=cc;
              if (IsWinning(ii, jj, kk+1, cc))
                Value[ii][jj]=-200;
              Fld[ii][jj][kk+1]=0;
            }
            for (iiw=0; iiw<4; iiw++)    
            { for (jjw=0; jjw<4; jjw++)
              { if ((kkw=FldCount[iiw][jjw])<4)
                { if (!((ii==iiw)&&(jj==jjw)))
                  { if ((vv=CanWin(iiw,jjw,kkw,-cc))==2)
                    { Fld[ii][jj][kk]=0;
                      Select(ii, jj);
                      return;
                    }
                    if (vv==-1)
                    Value[ii][jj]=-100;
                  }
                }
              }
            }
            Fld[ii][jj][kk]=cc;
            if (kk<3)
            { Fld[ii][jj][kk+1]=-cc;
              for (iiw=0; iiw<4; iiw++)    
              { for (jjw=0; jjw<4; jjw++)
                { if ((kkw=FldCount[iiw][jjw])<4)
                  { if (!((ii==iiw)&&(jj==jjw)))
                    { if (CanWin(iiw,jjw,kkw,-cc)==2)
                        Value[ii][jj]=-5000;
                    }
                  }
                }
              }
              Fld[ii][jj][kk+1]=0;
            }
          }
          Fld[ii][jj][kk]=0;
        }
      }
    }
  }
  if (nn==0)
  { IsOver=true; return; }
  zz=0; 
  nn=0;
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { if ((kk=FldCount[ii][jj])<4)
      { Fld[ii][jj][kk]=cc;
        if (kk<3)
        { Fld[ii][jj][kk+1]=-cc;
          if (IsWinning(ii, jj, kk+1, -cc))
          { vv=-8100;
            Fld[ii][jj][kk+1]=0;
          }
          else
          { Fld[ii][jj][kk+1]=0;
            vv=GetValue(ii, jj, kk, cc);
          }
        }
        else
          vv=GetValue(ii, jj, kk, cc);
        if (LLevel<2) vv%=200;
        if (LLevel<3) vv+=Math.floor(Math.random()*108);
        if (LLevel==3) vv+=Math.floor(Math.random()*27);
        Value[ii][jj]+=vv;
        if (zz==0) vvbest=Value[ii][jj];
        zz++;
        if (Value[ii][jj]==vvbest)
          nn++;
        if (Value[ii][jj]>vvbest)
        { nn=1;
          vvbest=Value[ii][jj];
        }
        Fld[ii][jj][kk]=0;
      }
    }
  }
  zz=Math.floor(Math.random()*nn);
  nn=-1;
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { if ((kk=FldCount[ii][jj])<4)
      { if (vvbest==Value[ii][jj])
        { nn++;
          if (nn==zz)
          { Select(ii, jj);
            return;
          }
        }
      }
    }
  }
}

function CanWin(ii, jj, kk, cc)
{ var kkl, kkk=kk-1;
  var vv=0;
  do
  { kkk++;
    Fld[ii][jj][kkk]=-cc;
    if ((IsWinning(ii, jj, kkk, -cc)))
    { for (kkl=kk; kkl<=kkk; kkl++)
        Fld[ii][jj][kkl]=0;
      if (kkk==kk) return(-1);
      else return(vv);
    }
    Fld[ii][jj][kkk]=cc;
    if ((IsWinning(ii, jj, kkk, cc))&&(kkk<3))
    { if (kkk==kk) vv++;
      Fld[ii][jj][kkk]=-cc;
      Fld[ii][jj][kkk+1]=cc;
      if ((IsWinning(ii, jj, kkk+1, cc)))
      { for (kkl=kk; kkl<=kkk+1; kkl++)
          Fld[ii][jj][kkl]=0;
        return(2);
      }
      Fld[ii][jj][kkk+1]=0;
    }
    Fld[ii][jj][kkk]=-cc;
  }
  while (kkk<3);
  for (kkl=kk; kkl<=kkk; kkl++)
    Fld[ii][jj][kkl]=0;
  return(vv);
}

function GetValue(ii, jj, kk, ccol)
{ var ll, cc, ccount1, ccount2, vval=0;
  var dd1, dd2, ddv, ddd, ddr;
  if (MoveCount%2==0)
  { dd1=1;
    dd2=1;
    ddv=(3-kk)*2;
    ddd=4; ddr=4;
    if (kk==2)
    { ddd=8; ddr=8; }
  }
  else
  { dd1=1;
    dd2=1;
    ddv=(3-kk)*(3-kk)+1;
    ddd=4; ddr=4;
    if (kk==2)
    { ddd=8; ddr=8; }
  }
  var ss1=0;
  var ss2=0;
  var ww1count=3*dd1;
  var ww1=0;
  var ww2count=2*dd2;
  var ww2=0;
  ccount1=0;
  ccount2=0;
  for (ll=0; ll<4; ll++)
  { if ((cc=Fld[ll][jj][kk])==ccol) ccount1+=dd1;
    if (cc==-ccol) ccount2+=dd2;
  }
  if ((ccount1>dd1)&&(ccount2>0));
  else
  { vval+=(ccount1+1)*(ccount2+1)*ddv;
    ss1+=ccount1-dd1; ss2+=ccount2;
    if (ccount1>=ww1count) ww1++;
    if (ccount2>=ww2count) ww2++;
  }
  ccount1=0;
  ccount2=0;
  for (ll=0; ll<4; ll++)
  { if ((cc=Fld[ii][ll][kk])==ccol) ccount1+=dd1;
    if (cc==-ccol) ccount2+=dd2;
  }
  if ((ccount1>dd1)&&(ccount2>0));
  else
  { vval+=(ccount1+1)*(ccount2+1)*ddv;
    ss1+=ccount1-dd1; ss2+=ccount2;
    if (ccount1>=ww1count) ww1++;
    if (ccount2>=ww2count) ww2++;
  }
  ccount1=0;
  ccount2=0;
  for (ll=0; ll<=kk; ll++)
  { if ((cc=Fld[ii][jj][ll])==ccol) ccount1+=dd1;
    if (cc==-ccol) ccount2+=dd2;
  }
  if ((ccount1>dd1)&&(ccount2>0));
  else
  { vval+=(ccount1+1)*(ccount2+1)*ddv;
    ss1+=ccount1-dd1; ss2+=ccount2;
    if (ccount1>=ww1count) ww1++;
    if (ccount2>=ww2count) ww2++;
  }
  if (jj==kk)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ii][ll][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if ((3-jj)==kk)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ii][3-ll][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if (ii==kk)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][jj][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if ((3-ii)==kk)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[3-ll][jj][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if (jj==ii)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][ll][kk])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }                         
  if ((3-jj)==ii)
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][3-ll][kk])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddd;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }                       
  if ((ii==jj)&&(jj==kk))
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][ll][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddr;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if ((ii==kk)&&((3-jj)==kk))
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][3-ll][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddr;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if ((ii==jj)&&(jj==(3-kk)))
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[ll][ll][3-ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddr;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if (((3-ii)==kk)&&(jj==kk))
  { ccount1=0;
    ccount2=0;
    for (ll=0; ll<4; ll++)
    { if ((cc=Fld[3-ll][ll][ll])==ccol) ccount1+=dd1;
      if (cc==-ccol) ccount2+=dd2;
    }
    if ((ccount1>dd1)&&(ccount2>0));
    else
    { vval+=(ccount1+1)*(ccount2+1)*ddr;
      ss1+=ccount1-dd1; ss2+=ccount2;
      if (ccount1>=ww1count) ww1++;
      if (ccount2>=ww2count) ww2++;
    }
  }
  if (ww1>1) vval+=ww1*4000;
  if (ss1>3*dd1) vval+=(ss1-3*dd1)*20;
  if ((ww2>=1)&&(ss2>2*dd2)) vval+=(ss2-2*dd2)*(kk+1)*50;
  if (ww2>1) vval+=ww2*500;
  return(vval);
}

function IsWinning(ii, jj, kk, ccol)
{ var ll, ccount;
  ccount=0;
  for (ll=0; ll<4; ll++)
  { if (Fld[ll][jj][kk]==ccol) ccount++;
  }
  if (ccount==4) return(true);
  ccount=0;
  for (ll=0; ll<4; ll++)
  { if (Fld[ii][ll][kk]==ccol) ccount++;
  }
  if (ccount==4) return(true);
  ccount=0;
  for (ll=0; ll<=kk; ll++)
  { if (Fld[ii][jj][ll]==ccol) ccount++;
  }
  if (ccount==4) return(true);
  if (jj==kk)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ii][ll][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((3-jj)==kk)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ii][3-ll][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if (ii==kk)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][jj][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((3-ii)==kk)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[3-ll][jj][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if (jj==ii)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][ll][kk]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((3-jj)==ii)
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][3-ll][kk]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((ii==jj)&&(jj==kk))
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][ll][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((ii==kk)&&((3-jj)==kk))
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][3-ll][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if ((ii==jj)&&(jj==(3-kk)))
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[ll][ll][3-ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  if (((3-ii)==kk)&&(jj==kk))
  { ccount=0;
    for (ll=0; ll<4; ll++)
    { if (Fld[3-ll][ll][ll]==ccol) ccount++;
    }
    if (ccount==4) return(true);
  }
  return(false);
}

function Select(ii, jj)
{ I_Sel=ii;
  J_Sel=jj;
  XMouseOver=ScreenFld[ii][jj][0];
  YMouseOver=ScreenFld[ii][jj][1];
  NeedBallDown=4;
}

function Clicked(xx, yy)
{ if (IsOver) return;
  if (NeedBallDown>0) return;
  MouseOut();
  MouseOver(xx, yy);
  if (XMouseOver>=0)
    NeedBallDown=4;
  window.document.OptionsForm.Moves.focus();
  window.document.OptionsForm.Moves.blur();

function MouseOver(xx, yy)
{ if (IsOver) return;
  if (XMouseOver>=0) return;
  if ((((MoveCount+Start0)%2==1)&&(IsPlayer[0]))||
      (((MoveCount+Start0)%2==0)&&(IsPlayer[1])))
  { if (NeedBallDown==0)
    { for (ii=0; ii<4; ii++)
      { for (jj=0; jj<4; jj++)
        { if ((ScreenFld[ii][jj][0]==xx)&&(ScreenFld[ii][jj][1]==yy))
          { if (Fld[ii][jj][3]==0)
            { if ((MoveCount+Start0)%2==1)
                window.document.images[13*yy+xx].src = Pic[1].src;
              else
                window.document.images[13*yy+xx].src = Pic[3].src;
              XMouseOver=xx;
              YMouseOver=yy;
              I_Sel=ii;
              J_Sel=jj;
            }
          }
        }
      }
    }
  }
}

function MouseOut()
{ if (IsOver) return;
  if (XMouseOver>=0)
  { if (NeedBallDown==0)
    { for (ii=0; ii<4; ii++)
      { for (jj=0; jj<4; jj++)
        { if ((ScreenFld[ii][jj][0]==XMouseOver)&&(ScreenFld[ii][jj][1]==YMouseOver))
            window.document.images[13*YMouseOver+XMouseOver].src = Pic[2+Fld[ii][jj][3]].src;
        }
      }
      XMouseOver=-1;
    }
  }

function RefreshPic(ii, jj, kk)
{ var xx=ScreenFld[ii][jj][0];
  var yy=ScreenFld[ii][jj][1];
  window.document.images[13*(yy+3-kk)+xx].src = Pic[2+Fld[ii][jj][kk]].src;
}

function RefreshScreen()
{ var ii, jj, kk, xx, yy;
  for (ii=0; ii<13; ii++)
  { for (jj=0; jj<13; jj++)
      window.document.images[13*ii+jj].src = Pic[0].src;
  }
  for (ii=0; ii<4; ii++)
  { for (jj=0; jj<4; jj++)
    { if (RotAng==0) { xx=3*ii+jj; yy=9-2*jj+ii; }
      if (RotAng==1) { xx=3*ii+3-jj; yy=9-2*jj+3-ii; }
      if (RotAng==2) { xx=3*(3-jj)+ii; yy=9-2*ii+(3-jj); }
      if (RotAng==3) { xx=3*(3-jj)+3-ii; yy=9-2*ii+3-(3-jj); }
      if (RotAng==4) { xx=3*(3-ii)+(3-jj); yy=9-2*(3-jj)+(3-ii); }
      if (RotAng==5) { xx=3*(3-ii)+3-(3-jj); yy=9-2*(3-jj)+3-(3-ii); }
      if (RotAng==6) { xx=3*jj+(3-ii); yy=9-2*(3-ii)+jj; }
      if (RotAng==7) { xx=3*jj+3-(3-ii); yy=9-2*(3-ii)+3-jj; }
      ScreenFld[ii][jj][0]=xx;
      ScreenFld[ii][jj][1]=yy-3;    
      for (kk=0; kk<4; kk++)
        window.document.images[13*(yy-kk)+xx].src = Pic[2+Fld[ii][jj][kk]].src;
    }
  }
  window.document.OptionsForm.Moves.value=MoveCount;
}

function Resize()
{ if(navigator.appName == “Netscape”) history.go(0);
}
//  End –>
</script>

</HEAD>

<BODY onResize=”javascript:Resize()”>

<DIV ALIGN=center>
<table noborder cellpadding=10 cellspacing=0 width=650 heigth=390>
<tr height=100%>
  <td width=60%>
    <table border cellpadding=10 cellspacing=0 bgcolor=#FFFFCC width=100%><tr><td>
      <table noborder cellpadding=0 cellspacing=0><tr><td>
      <script language=”JavaScript”>
      document.open(“text/plain”);
      for (j=0; j < 13; j++)
      { for (i=0; i < 13; i++)
          document.write(“<a href=\”javascript:Clicked(“+i+”,”+j+”)\” onMouseOver=\”MouseOver(“+i+”,”+j+”)\” onMouseOut=\”MouseOut()\”><IMG src=\”tt3d_0.gif\” border=0></a>”);
        document.writeln(“<BR>”);
      }
      document.close();
      </script>
      </td></tr></table>
    </td></tr></table>
  </td>
  <td width=40%><form name=”OptionsForm”>
      <table noborder cellpadding=0 cellspacing=0 width=100%>
      <tr><td> </td></tr>
      <tr><td>
        <table border cellpadding=2 cellspacing=0 width=100%>
        <tr><td><input type=radio name=”Red” checked value=”Red: Player” onClick=”javascript:SetOption(0,0)”> Red: Player</td></tr>
        <tr><td><input type=radio name=”Red” value=”Red: Computer” onClick=”javascript:SetOption(0,1)”> Red: Computer</td></tr>
        <tr><td> Level:
                <input type=radio name=”RedLevel” value=”1″ onClick=”javascript:SetLevel(0,1)”>1
                <input type=radio name=”RedLevel” checked value=”2″ onClick=”javascript:SetLevel(0,2)”>2
                <input type=radio name=”RedLevel” value=”3″ onClick=”javascript:SetLevel(0,3)”>3
                <input type=radio name=”RedLevel” value=”4″ onClick=”javascript:SetLevel(0,4)”>4
        </td></tr>
        </table>     
      </td></tr>
      <tr><td> </td></tr>
      <tr><td>
        <table border cellpadding=2 cellspacing=0 width=100%>
        <tr><td><input type=radio name=”Blue” value=”Blue: Player” onClick=”javascript:SetOption(1,0)”> Blue: Player</td></tr>
        <tr><td><input type=radio name=”Blue” checked value=”Blue: Computer” onClick=”javascript:SetOption(1,1)”> Blue: Computer</td></tr>
        <tr><td> Level:
                <input type=radio name=”BlueLevel” value=”1″ onClick=”javascript:SetLevel(1,1)”>1
                <input type=radio name=”BlueLevel” value=”2″ onClick=”javascript:SetLevel(1,2)”>2
                <input type=radio name=”BlueLevel” checked value=”3″ onClick=”javascript:SetLevel(1,3)”>3
                <input type=radio name=”BlueLevel” value=”4″ onClick=”javascript:SetLevel(1,4)”>4
        </td></tr>
        </table>
      </td></tr>
      <tr><td> </td></tr>
      <tr><td>
        <table border cellpadding=2 cellspacing=0 width=100%>
        <tr><td width=50%><input type=radio name=”Start” checked value=”Red” onClick=”javascript:SetOption(2,1)”> Red begins</td>
        <td><input type=radio name=”Start” value=”Blue” onClick=”javascript:SetOption(2,0)”> Blue begins</td></tr>
        </table>
      </td></tr>
      <tr><td> </td></tr>
      <tr><td>
        <table border cellpadding=2 cellspacing=0 width=100%><tr>
        <td width=30% align=center><input type=button value=”<-” width=60 style=”width:60″ onClick=”javascript:TurnLeft()”></td>
        <td width=40% align=center><input type=button value=”NEW” width=80 style=”width:80″ onClick=”javascript:Init()”></td>
        <td width=30% align=center><input type=button value=”->” width=60 style=”width:60″ onClick=”javascript:TurnRight()”></td>
        </tr></table>
      </td></tr>
      <tr><td> </td></tr>
      <tr><td>
        <table border cellpadding=2 cellspacing=0 width=100%><tr>
        <td width=40% align=center><input type=button value=”<<” width=80 style=”width:80″ onClick=”javascript:Back()”></td>
        <td width=20% align=center><input size=3 name=”Moves”></td>
        <td width=40% align=center><input type=button value=”>>” width=80 style=”width:80″ onClick=”javascript:Replay()”></td>
        </tr></table>
      </td></tr>
      </table>
  </form></td>
</tr>
</table>
</DIV>
<script language=”JavaScript”>
Init();
setInterval(“Timer()”,400);
</script>

Posted in 2. Games | Leave a Comment »

Mind Reader…realy amazing

Posted by paragdongre on November 12, 2007

Hi Friends!
Now u must used to it, simply copy paste this javascript code in notepad and save it as “.HTML” file format.
and start playing.

[Note: Plz dont make any type of updation in the code before copying it.]
—————————————————————————————-

 <HTML>

<HEAD>

<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
var cards = new Array(6);
var play = 0;
var cn = 0;
var ttl = 0;
cards[1] = ”        CARD  ONE        \n  1  3  5  7  9 11 13 15 \n 17 19 21 23 25 27 29 31 \n 33 35 37 39 41 43 45 47 \n 49 51 53 55 57 59 61 63″;
cards[2] = ”        CARD  TWO        \n  2  3  6  7 10 11 14 15 \n 18 19 22 23 26 27 30 31 \n 34 35 38 39 42 43 46 47 \n 50 51 54 55 58 59 62

63″;
cards[3] = ”       CARD  THREE       \n  4  5  6  7 12 13 14 15 \n 20 21 22 23 28 29 30 31 \n 36 37 38 39 44 45 46 47 \n 52 53 54 55 60 61 62

63″;
cards[4] = ”        CARD FOUR        \n  8  9 10 11 12 13 14 15 \n 24 25 26 27 28 29 30 31 \n 40 41 42 43 44 45 46 47 \n 56 57 58 59 60 61 62

63″;
cards[5] = ”        CARD FIVE        \n 16 17 18 19 20 21 22 23 \n 24 25 26 27 28 29 30 31 \n 48 49 50 51 52 53 54 55 \n 56 57 58 59 60 61 62

63″;
cards[6] = ”        CARD  SIX        \n 32 33 34 35 36 37 38 39 \n 40 41 42 43 44 45 46 47 \n 48 49 50 51 52 53 54 55 \n 56 57 58 59 60 61 62

63″;
var ccol = new Array(“”,”#FF7777″,”Green”,”Blue”,”Gray”,”Red”,”Black”);
var knos = new Array(“”,1,2,4,8,16,32);
function Nextcard() {
cn++;
if(cn == 7)
End();
else {
document.x.card.value=cards[cn];
document.x.card.style.backgroundColor=ccol[cn];
document.x.text.value=”Is your number on the card above?”;
   }
}
function Restart() {
play=0;
cn=0;
ttl=0;
document.x.card.style.backgroundColor = “#FFFFFF”;
document.x.card.style.color = “#000000”;
document.x.card.value = “Think of a number between 1 and 63. Six cards will be displayed. After the last one, your number is revealed.”;
document.x.text.value = “Click Start”;
document.x.stbt.value = “Start”;
}
function Yes() {
ttl = ttl + knos[cn];
Nextcard();
}
function Start() {
document.x.card.style.color = “White”;
document.x.stbt.value = “Restart”;
play = 1;
Nextcard();
}
function End() {
play = 2;
if(ttl < 10)
ttl = ” ” + ttl;
ttl = ” ” + ttl;
var one = ttl.charAt(1);
var two = ttl.charAt(2);
document.x.card.value = “\n   THE NUMBER YOU WERE   \n    THINKING OF WAS :    \n      — [ “+one+” “+two+” ] –“;
document.x.card.style.color = “Red”;
document.x.text.value = “Click Restart to play again”;
}
function click() {
event.cancelBubble = true;
event.returnValue = false;
}
document.oncontextmenu = click;
//  End –>
</script>

</HEAD>

<BODY>

<form name=”x”>
<center>
<table border=”0″>
<tr>
<td><b>
<center>
<textarea name=”card” rows=”7″ cols=”25″>Think of a number between 1 and 63. Six cards will be displayed. After the last one, your

number is revealed.
</textarea>
</center></b>
</td>
</tr>
<tr>
<td>
<center>
<input type=”text” size=”36″ name=”text” value=”Click Start” style=”FONT-SIZE: 10pt”>
</center>
</td>
</tr>
<tr>
<td>
<center>
<input type=”button” value=”YES” onclick=”if(play==1) Yes()” style=”FONT-SIZE: 10pt”>
<input type=”button” value=”NO” onclick=”if(play==1) Nextcard()” style=”FONT-SIZE: 10pt”>
<input type=”button” name=”stbt” value=” Start ” onclick=”if(play==0) Start(); else Restart()” style=”FONT-SIZE: 10pt”>
</center>
</td>
</tr>
</table>
</center>
</form>
</BODY>
</HTML>

Posted in 3. Fun | Leave a Comment »

Interveiw answers we need to know.

Posted by paragdongre on November 8, 2007

Q1 Tell me about yourself.
Q2 What are your greatest strengths?
Q3 What are your greatest weaknesses?
Q4 Tell me about something you did – or failed to do – that you now feel a little ashamed of.
Q5 Why are you leaving (or did you leave) this position?
Q6 The “Silent Treatment”
Q7 Why should I hire you?
Q8 Aren’t you overqualified for this position?
Q9 Where do you see yourself five years from now?
Q10 Describe your ideal company, location and job.
Q11 Why do you want to work at our company?
Q12 What are your career options right now?
Q13 Why have you been out of work so long?
Q14 Tell me honestly about the strong points and weak points of your boss (company, management team, etc.)
Q15 What good books have you read lately?
Q16 Tell me about a situation when your work was criticized.
Q17 What are your outside interest?
Q18 The “Fatal Flaw” question
Q19 How do you feel about reporting to a younger person (minority, woman, etc)?
Q20 On confidential matters
Q21 Would you lie for the company?
Q22 Looking back, what would you do differently in your life?
Q23 Could you have done better in your last job?
Q24 Can you work under pressure?
Q25 What makes you angry?
Q26 Why aren’t you earning more money at this stage of your career?
Q27 Who has inspired you in your life and why?
Q28 What was the toughest decision you ever had to make?
Q29 Tell me about the most boring job you’ve ever had.
Q30 Have you been absent from work more than a few days in any previous position?
Q31 What changes would you make if you came on board?
Q32 I’m concerned that you don’t have as much experience as we’d like in
Q33 How do you feel about working nights and weekends?
Q34 Are you willing to relocate or travel?
Q35 Do you have the stomach to fire people? Have you had experience firing many people?
Q36 Why have you had so many jobs?
Q37 What do you see as the proper role/mission of… …a good (job title you’re seeking); …a good manager; …an executive in serving the community; …a leading company in our industry; etc.
Q38 What would you say to your boss if he’s crazy about an idea, but you think it stinks?
Q39 How could you have improved your career progress?
Q40 What would you do if a fellow executive on your own corporate level wasn’t pulling his/her weight…and this was hurting your department?
Q41 You’ve been with your firm a long time. Won’t it be hard switching to a new company?
Q42 May I contact your present employer for a reference?
Q43 Give me an example of your creativity (analytical skill…managing ability, etc.)
Q44 Where could you use some improvement?
Q45 What do you worry about?
Q46 How many hours a week do you normally work?
Q47 What’s the most difficult part of being a (job title)?
Q48 The “Hypothetical Problem”
Q49 What was the toughest challenge you’ve ever faced?
Q50 Have you consider starting your own business?
Q51 What are your goals?
Q52 What do you for when you hire people?
Q53 Sell me this stapler…(this pencil…this clock…or some other object on interviewer’s desk).
Q54 “The Salary Question” – How much money do you want?
Q55 The Illegal Question
Q56 The “Secret” Illegal Question
Q57 What was the toughest part of your last job?
Q58 How do you define success…and how do you measure up to your own definition?.
Q59 “The Opinion Question” – What do you think about …Abortion…The President…The Death Penalty…(or any other controversial subject)?
Q60 If you won $10 million lottery, would you still work?
Q61 Looking back on your last position, have you done your best work?
Q62 Why should I hire you from the outside when I could promote someone from within?
Q63 Tell me something negative you’ve heard about our company
Q64 On a scale of one to ten, rate me as an interviewer.

Posted in 5. Tips | Leave a Comment »