Saturday, May 7, 2011

VB.net Tutorial 3.1 : Control stuctures

Control stuctures :


If : usefull to make condition in your code


example : if nb<5 then command()

OR

if nb<5 then
command()
end if


OR

if nb<5 then
command1()
else
command2()
end if


Select Case

An example is better than lot of text so :
example :
select case nb
case is <=10
Msgbox("the number is < 10")
case 11 to 19
Msgbox("the number is betwen 11 and 19")
case else
command1()
end select

IIF : evaluates a condition and returns different values regarding the result of the condition


example : IIF(condition, value_if_true,value_if false)


While : repeat instruction until the condition is false

example : while condition
...
end while

Do Loop : can be used with the keywords while or until

example : do
...
loop while condition

OR

do
...
loop until condition

For : The for structure is used to execute a bloc a number of time with a counter.

example : dim i as integer
for i = 1 to 10 step 2
msgbox(i)
next


For each : Very usefull to access evry element in an array.

example : For each element in foobar 'foobar is the array to access
...
next





Friday, May 6, 2011

VB.net Tutorial 2 : The language

Basis 

Forms

The code is very similar to the VB6 language.
For example : making a form is pretty easy :
the instruction "inherits System.windows.forms.form" is to explain that the class we create must inherit from all elements in the class "form".

Modules

 When building a new module that code is generated.
All the code contained in the module will be inserted between "Module" and "End Module"




Commentaries

Commentaires are used to add information on the code and will not be executed and removed from the final code.

To add a comment you can use the " ' " character.
example : 'this is a commentarie

Variables

Byte :  from 0 to 255

Short : from -32768 to 32767

Integer : from -2 147 483 648 to 2 147 483 647

long : from  -9223372036854775808 to 9223372036854775807

Strings


Char : used for 1 character
String : for multiples characters
to declare a variable you just have to type : Dim variablename as type

example : Dim i as integer
Dim myvar as string
Dim today as date

Arrays

Arrays can be used to store more than one information in one variable.
to declare an array the syntax is :
Dim myarray(10) as integer
to declare an array of 10 integer
to use an element of the array type : myarray(number)

example :

myarray(2)=5
mystring(1)="helloworld"
to change the size of an array, use the "redim" keyword

example :

dim foobar(10) as array 'declare an array of 10 elements
redim foobar(15) 'changes the size of the array to 15 elements
redim preserve foobar(20 'changes the size without destroying elements

Constants

Constants are usefull to store data wich is not subjet to changes.
example : dim constant = 10

Operators

To set a value to a variable, use the "=" operator
example :
dim foo as integer
foo= 4
is equivalent to
dim foo as integer=4

Other operators :

+ : addition

- : subtraction

* : multiplication

/ : division

^ : power

= : equals

<> : not equal

< : inferior

> : superior

<= : inferior or equal

>= : superior or equal

Like : for strings

VB.net Tutorial 1 : Environement

As i know it's not easy to start a new language i decided to make a tutorial : this is the first part, it only shows the environment of the IDE.

Installation

What you need is :
processor : P2 450Mhz
RAM : 128mo
Disk space 3Gb
VideoCard : 800x600 256 colors
CD Drive
OS : all from windows 2K

Environnement 
 

The right part is the solution explorator and the property window.
At the center, like in VB6 this is the graphical user interface.











This is used to list all the objects of a server (SQL servers, papers or services...) This window in principally used for accessing the scheme of a database used in a application.












The solution explorer save all the elements of your project ( configuration files, file for assembly, inherited classes, sheets...)

A solution contains those elements :
.sln : file configuration project
.vbproj : project file ( it was named .vbp in VB6)
.vb : file containing code (like .bas or .frm in VB6)
.resx





Classes display is used to list your classes, method, properties events and other relations.







Already present in the 6.0 version this window lists all the property relatively to the selected object.









Project management

To create a project : file -> New -> Project.







The main project you can make are :
  • Windows Application
  • Class library
  • Smart device application
  • Application web ASP.net
  • Service web ASP.net
  • Console application
  • Windows service



Configuring your project

Name of the assembly : Name of the file generated after compilation
Exit Type : What type of application.
Start object : sheet using to start the program.
Namspace root : Used to define a préfix for using with all classes available in your project
Icon : The .ico file used to define the Icon of your application
Option Explicit : forbid using a variable not declared
Namespace : Allows you to define namespaces that will be automatically imported in your project
Path : Define the folder where are the references used in the project.
Language of script client : Type of language used.

Compilation constants : this option is used to define constants for your code.
Exit path : Folder where your application will be built.
Work path : Active path for your application

Minecraft

Minecraft has reached 2 million sales !
For those who don't know what is minecraft :
Minecraft is an addictive game in which you can destroy, or creates 1m blocks like sand, rock or wood block.
But what is awesome in that game is that it's an FPS so you can really live in what you build.
Other interesting stuff is redstone wire that allows you to connect things like lamps piston or music box.
Rails are also very fun : you can make your own circuits of minecarts powered by resdstone.
Servers are free : evrybody can host a server, you just need to have bought the game once and its low cost (10€) makes it very affordable.
The community is pretty nice : lots of mods are available and servers are great. The only problem in my opinion is that the game take a lot of resources for the server so it costs a lot to host a simple server.

Here's an example of a city build by players.
The game itself make is very enjoyable to play and to build and you'll not notice losing tons of hours when you play.
But the game is only in beta so it's gonna be way better ! For example, Notch, the director of Mojang plan to add modding support to Minecraft in some updates.
Here is a link to minecraft.net the official website.
Have fun !

Thursday, May 5, 2011

Garry's mod

Always wanted to be in a world where you can create what you want ?
This dream is now possible with garry's mod !
Even if it's old, it's still a pleasure to play this "game" : Built on the source engine, it let the user make everything he wants from a simple boat with some wooden plate and thrusters to a complex helicopter based on the control theory.
Moreover there is a lot of mods like 
  • Fort wars where you have to build a fort to protect yourself while you keep the ball in the fort
  • Flood mode where you have to survive against enemies when all you have is weapons and a boat
  • Race : You build your own car and fight against other players !
  • RP : play role play in a city (not my favourite)
  • Maybe the best mode : Sandbox : build what you want !

Here are an example of the thing you can make in the sandbox : by placing baloons on something you can make a ballooning.
With some plates and elastics you can make a catapult.
With a sensors and a turret you can design your own killing machine !




And a lot more...

What is Perl ?

I just re-discovered Perl and I wanted to share my passion for this programming language.
It's easy to use, very powerful and multiplatform. It has been created in 1987 and it use some of the fonctionality of the C language.
It's very efficient for string computing with this very powerfull regulars expressions.
What is great with Perl is that it has a lot of libraries like for socket using or for http access.

Example of the syntax : 
my %foo = ( bar1 => [1,2], bar2 => [3,4});

Example of programs made in Perl :

  • Bugzilla
  • Irc bots
have a look on http://www.perl.org/



Portal 2

I bought it yesterday, and i just finished it. It's awesome ! I recommend it to everybody, even if the game is very short (count about 8 hours to end the game in solo mode and the same amount for the coop mode.)
Moreover, developers say that they will release a tool to easily create maps.
I can't say more without spoiling you, so I'll just say : get it !

Torchligh 3 before Diablo 3 ?

Max shaefer, the president and cofoundator of Runic Games announced that Torchlight 3 will be released before Diablo 3. He obviously was joking about the game politic of Blizzard.

But what about Torchlight 2 ?
It's intresting to know that Runic Games listened the wishes of many players wich is to see cooperation mode in Torchligh II. And it seems that it's gonna be great ! More classes, more game play multiplayer and a lot more !
The only thing is that we have to wait until this summer.

Official release of PHP 5.3

The release of php 5.3 has been announced !
the main evolutions are :
  • Namespaces
  • "Late static bindings"
  • Many bug corrected
and a lot more

official links :

http://www.php.net/release/5_3_0.php
http://www.php.net/ChangeLog-5.php#5.3.0
http://php.net/downloads.php#v5.3.0