First Steps With PHP

This is a small tutorial that will help you start with PHP
Writing PHP
Writing PHP on your computer is actually very simple. You don't need any specail software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.
Declaring PHP
PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:



All of these work in exactly the same way but in this tutorial I will be using the first option (). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can't start with for example).
Your First Script
The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:

As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server.
One other thing you should notice in this example is that the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error.
Finishing and Testing Your Script
Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server.
If your script doesn't work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed, you are prompted to download the file, PHP is not installed on your server and you should either serach for a new web host or ask your current host to install PHP.
It is a good idea to keep this script for future reference.
Printing Text
To output text in your PHP script is actually very simple. As with most other things in PHP, you can do it in a variety of different ways. The main one you will be using, though, is print. Print will allow you to output text, variables or a combination of the two so that they display on the screen.
The print statement is used in the following way:
print("Hello world!");
I will explain the above line:
print is the command and tells the script what to do. This is followed by the information to be printed, which is contained in the brackets. Because you are outputting text, the text is also enclosed instide quotation marks. Finally, as with nearly every line in a PHP script, it must end in a semicolon. You would, of course, have to enclose this in your standard PHP tags, making the following code:

Which will display:
Hello world!
on the screen.
Variables
As with other programming languages, PHP allows you to define variables. In PHP there are several variable types, but the most common is called a String. It can hold text and numbers. All strings begin with a $ sign. To assign some text to a string you would use the following code:
$welcome_text = "Hello and welcome to my website.";
This is quite a simple line to understand, everything inside the quotation marks will be assigned to the string. You must remember a few rules about strings though:
Strings are case sensetive so $Welcome_Text is not the same as $welcome_text String names can contain letters, numbers and underscores but cannot begin with a number or underscore When assigning numbers to strings you do not need to include the quotes so:
$user_id = 987
would be allowed.
Outputting Variables
To display a variable on the screen uses exactly the same code as to display text but in a slightly different form. The following code would display your welcome text:

As you can see, the only major difference is that you do not need the quotation marks if you are printing a variable.
Formatting Your Text
Unfortunately, the output from your PHP programs is quite boring. Everything is just output in the browser's default font. It is very easy, though, to format your text using HTML. This is because, as PHP is a server side language, the code is executed before the page is sent to the browser. This means that only the resulting information from the script is sent, so in the example above the browser would just be sent the text:
Hello and welcome to my website.
This means, though, that you can include standard HTML markup in your scripts and strings. The only problem with this is that many HTML tags require the " sign. You may notice that this will clash with the quotation marks used to print your text. This means that you must tell the script which quotes should be used (the ones at the beginning and end of the output) and which ones should be ignored (the ones in the HTML code).
For this example I will change the text to the Arial font in red. The normal code for this would be:

As you can see this code contains 4 quotation marks so would confuse the script. Because of this you must add a backslash before each quotation mark to make the PHP script ignore it. The code would change to:

You can now include this in your print statement:
print("Hello and welcome to my website.");
which will make the browser display:
Hello and welcome to my website.
because it has only been sent the code:
Hello and welcome to my website.
This does make it quite difficult to output HTML code into the browser but later in this tutorial I will show you another way of doing this which can make it a bit easier.
The Basics Of IF
If statements are used to compare two values and carry out different actions based on the results of the test. If statements take the form IF, THEN, ELSE. Basically the IF part checks for a condition. If it is true, the then statement is executed. If not, the else statement is executed.
IF Strucure
The structure of an IF statement is as follows:
IF (something == something else){THEN Statement} else {ELSE Statement}
Variables
The most common use of an IF statement is to compare a variable to another piece of text, a number, or another variable. For example:
if ($username == "webmaster")
which would compare the contents of the variable to the text string. The THEN section of code will only be executed if the variable is exactly the same as the contents of the quotation marks so if the variable contained 'Webmaster' or 'WEBMASTER' it will be false.
Constructing The THEN Statment
To add to your script, you can now add a THEN statement:
if ($username == "webmaster") {echo "Please enter your password below";}
This will only display this text if the username is webmaster. If not, nothing will be displayed. You can actually leave an IF statement like this, as there is no actual requirement to have an ELSE part. This is especially useful if you are using multiple IF statements.
Constructing The ELSE Statement
Adding The ELSE statement is as easy as the THEN statement. Just add some extra code:
if ($username == "webmaster") {echo "Please enter your password below";} else {echo "We are sorry but you are not a recognised user";}
Of course, you are not limited to just one line of code. You can add any PHP commands in between the curly brackets. You can even include other IF statments (nested statements).
Other Comparisons
There are other ways you can use your IF statement to compare values. Firstly, you can compare two different variables to see if their values match e.g.
if ($enteredpass == $password)
You can also use the standard comparision symbols to check to see if one variable is greater than or less than another:
if ($age < "13")
Or :
if ($date > $finished)
You can also check for multiple tests in one IF statement. For instance, if you have a form and you want to check if any of the fields were left blank you could use:
if ($name == "" $email == "" $password == "") {echo "Please fill in all the fields";}

PHP

Welcome to the PHP (HyperText Processor) Section

What Is PHP?PHP stands for Hypertext Preprocessor and is a server-side language. This means that the script is run on your web server, not on the user's browser, so you do not need to worry about compatibility issues. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becomming one of the most popular scripting languages on the internet
Why PHP?You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website. Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.Using scripts on your website allows you to add many new 'interactive' features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sort of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.What Do I Need?As mentioned earlier, PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don't know if it is installed you can find out using the first script in this tutorial. If you server does not support PHP you can ask your web host to install it for you as it is free to download and install. If you need a low cost web host which supports PHP I would recommmend HostRocket.
Here's some tutorials about PHP

First Steps with PHP

Win32Api

As I wanted to make some programing task with Win32Api and VB.net, I would like to share my experience with others. So I began collecting information on the win32api and how it works.
Short Description :
The Windows API, informally WinAPI, is the name given by Microsoft to the core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. All Windows programs except console programs must interact with the Windows API regardless of the language.
The functionality provided by the Windows API can be grouped into seven categories:
Base Services
Provide access to the fundamental resources available to a Windows system. Included are things like file systems, devices, processes and threads, access to the Windows registry, and error handling. These functions reside in kernel.exe, krnl286.exe or krnl386.exe files on 16-bit Windows, and kernel32.dll and advapi32.dll on 32-bit Windows.
Graphics Device Interface
Provide the functionality for outputting graphical content to monitors, printers and other output devices. It resides in gdi.exe on 16-bit Windows, and gdi32.dll on 32-bit Windows.
User Interface
Provides the functionality to create and manage screen windows and most basic controls, such as buttons and scrollbars, receive mouse and keyboard input, and other functionality associated with the GUI part of Windows. This functional unit resides in user.exe on 16-bit Windows, and user32.dll on 32-bit Windows. Since Windows XP versions, the basic controls reside in comctl32.dll, together with the common controls (Common Control Library).
Common Dialog Box Library
Provides applications the standard dialog boxes for opening and saving files, choosing color and font, etc. The library resides in a file called commdlg.dll on 16-bit Windows, and comdlg32.dll on 32-bit Windows. It is grouped under the User Interface category of the API.
Common Control Library
Gives applications access to some advanced controls provided by the operating system. These include things like status bars, progress bars, toolbars and tabs. The library resides in a DLL file called commctrl.dll on 16-bit Windows, and comctl32.dll on 32-bit Windows. It is grouped under the User Interface category of the API.
Windows Shell
Component of the Windows API allows applications to access the functionality provided by the operating system shell, as well as change and enhance it. The component resides in shell.dll on 16-bit Windows, and shell32.dll and later in Windows 95 shlwapi.dll on 32-bit Windows. It is grouped under the User Interface category of the API.
Network Services
Give access to the various networking capabilities of the operating system. Its sub-components include NetBIOS, Winsock, NetDDE, RPC and many others.
Web
The Internet Explorer web browser also exposes many APIs that are often used by applications, and as such could be considered a part of the Windows API. Internet Explorer has been an integrated component of the operating system since Windows 98, and provides web related services to applications.[10] The integration has stopped with Windows Vista. Specifically, it used to provide:
An embeddable web browser control, contained in shdocvw.dll and mshtml.dll.
The URL monitor service, held in urlmon.dll, which provides COM objects to applications for resolving URLs. Applications can also provide their own URL handlers for others to use.
A library for assisting with multi-language and international text support (mlang.dll).
DirectX Transforms, a set of image filter components.
XML support (the MSXML components).
Access to the Windows Address Book.
Multimedia
Microsoft has provided the DirectX set of APIs as part of every Windows installation since Windows 95 OSR2. DirectX provides a loosely related set of multimedia and gaming services, including:
Direct3D as an alternative to OpenGL for access to 3D acceleration hardware.
DirectDraw for hardware accelerated access to the 2D framebuffer. As of DirectX 9, this component has been deprecated in favor of Direct3D, which provides more general high-performance graphics functionality (as 2D rendering is a subset of 3D rendering).
DirectSound for low level hardware accelerated sound card access.
DirectInput for communication with input devices such as joysticks and gamepads.
DirectPlay as a multiplayer gaming infrastructure. This component has been deprecated as of DirectX 9 and Microsoft no longer recommends its use for game development.
DirectShow which builds and runs generic multimedia pipelines. It is comparable to the GStreamer framework and is often used to render in-game videos and build media players (Windows Media Player is based upon it). DirectShow is no longer recommended for game development.
DirectMusic
Program interaction
The Windows API mostly concerns itself with the interaction between the operating system and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out with Dynamic Data Exchange (DDE), which was superseded by Object Linking and Embedding (OLE) and later by the Component Object Model (COM).

Wrapper libraries
Various wrappers were developed by Microsoft that took over some of the more low level functions of the Windows API, and allowed applications to interact with the API in a more abstract manner. Microsoft Foundation Class Library (MFC) wrapped Windows API functionality in C++ classes, and thus allows a more object oriented way of interacting with the API. The Active Template Library (ATL) is a template oriented wrapper for COM. The Windows Template Library (WTL) was developed as an extension to ATL, and intended as a lightweight alternative to MFC.
Also notable are some of Borland's offerings. Object Windows Library (OWL) was released as a competing product to MFC, and offered a similar object-oriented wrapper. Borland later deprecated it in favour of the Visual Component Library (VCL).
All application frameworks for Windows are (at least partially) wrapping the Windows API. Thus, the .NET Framework and Java, as well as any other programming languages under Windows, are (or contain) Wrapper Libraries.

Will post more about programing Win32Api and VB.net
Questions, leave a comment

Tracert Command Line

The Tracert command is origine from the word "Trace Route"
traceroute is a computer network tool used to determine the route taken by packets across an IP network. An IPv6 variant, traceroute6, is also widely available.
Traceroute is often used for network troubleshooting. By showing a list of routers traversed, it allows the user to identify the path taken to reach a particular destination on the network. This can help identify routing problems or firewalls that may be blocking access to a site. Traceroute is also used by penetration testers to gather information about network infrastructure and IP ranges around a given host. It can also be used when downloading data, and if there are multiple mirrors available for the same piece of data, one can trace each mirror to get a good idea of which mirror would be the fastest to use.
Traceroute works by increasing the "time-to-live" value of each successive batch of packets sent. The first three packets have a time-to-live (TTL) value of one (implying that they make a single hop). The next three packets have a TTL value of 2, and so on. When a packet passes through a host, normally the host decrements the TTL value by one, and forwards the packet to the next host. When a packet with a TTL of one reaches a host, the host discards the packet and sends an ICMP time exceeded (type 11) packet to the sender. The traceroute utility uses these returning packets to produce a list of hosts that the packets have traversed en route to the destination. The three timestamp values returned for each host along the path are the delay (aka latency) values typically in milliseconds (ms) for each packet in the batch. If a packet does not return within the expected timeout window, a star (asterisk) is traditionally printed. traceroute may not list the real hosts. It indicates that the first host is at one hop, the second host at two hops, etc. IP does not guarantee that all the packets take the same route. Also note that if the host at hop number N does not reply, the hop will be skipped in the output.
Questions leave a comment

How to use Ping

This is another command line in this Network tutorials.
ping is a computer network tool used to test whether a particular host is reachable across an IP network. It works by sending ICMP "echo request" packets to the target host and listening for ICMP "echo response" replies. ping estimates the round-trip time, generally in milliseconds, and records any packet loss, and prints a statistical summary when finished.
To use Ping
1/ Open "Execute" or the command line
2/ type "Ping" and any IP or Host name you like
The Ping command will return information that should be like :
Envoi d'une requête 'ping' sur VECTRA [127.0.0.1] avec 32 octets de données :
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Statistiques Ping pour 127.0.0.1:
Paquets : envoyés = 4, reçus = 4, perdus = 0 (perte 0%),
Durée approximative des boucles en millisecondes :
Minimum = 0ms, Maximum = 0ms, Moyenne = 0ms
Ping will return TTL (Time to Live) and also if the server responded.
Results may be :
+ : The server respond
+ : The server is connected but don't respond
- : Ping can't find the server
Questions ? Leave a comment

How to use IPConfig

This is a short smart tutorial about IPConfig. Ipconfig is a command line that displays information about your Network Card and Connection
How to use : Follow the following steps
1/Go to the start menu and select Run.... Then type cmd in the box and click OK.
2/At the C:\> prompt type ipconfig . Then press Enter. Your IP address, subnet mask and default gateway will be returned to you. If your IP address is 192.168.x.x, 10.x.x.x, or 172.16.x.x, then you are receiving an internal IP address from a router or other device. The IP address that the world sees is that of the router. If you are receiving a 169.254.x.x address, this is a Windows address that generally means your network connection is not working properly
3/If you want more detailed information about your network connection, type ipconfig /all at the prompt. Here you can get the same information as ipconfig with the addition of your MAC (hardware) address, DNS and DHCP server addresses, IP lease information, etc. If your IP address is 192.168.x.x, 10.x.x.x, or 172.16.x.x, then you are receiving an internal IP address from a router or other device. The IP address that the world sees is that of the router. If you are receiving a 169.254.x.x address, this is a Windows address that generally means your network connection is not working properly.
4/If you are having trouble with your ResNet connection, it may be fixed by releasing and renewing your IP address. Type ipconfig /release at the prompt and press enter. Then type ipconfig /renew and press enter again. If your connection is okay, a valid IP address, subnet mask and default gateway will be returned to you after a few seconds
Questions ? Leave a comment

Windows PowerShell

What's after DOS ?? Windows PowerShell come with a lot of new features that will help especially Network and DNS developers.
Windows PowerShell is (I think) buitl with Visual C#, because it's programing language is C.
What's Windows Shell ?
That what you may ask ! Windows PowerShell is a new Windows command-line shell designed especially for system administrators. The shell includes an interactive prompt and a scripting environment that can be used independently or in combination.
Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET common language runtime (CLR) and the .NET Framework, and accepts and returns .NET objects. This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.
Windows PowerShell introduces the concept of a cmdlet (pronounced "command-let"), a simple, single-function command-line tool built into the shell. You can use each cmdlet separately, but their power is realized when you use these simple tools in combination to perform complex tasks. Windows PowerShell includes more than one hundred basic core cmdlets, and you can write your own cmdlets and share them with other users.
Like many shells, Windows PowerShell gives you access to the file system on the computer. In addition, Windows PowerShell providers enable you to access other data stores, such as the registry and the digital signature certificate stores, as easily as you access the file system.
Requirement for Windows PowerShell
You'll need only Ms Dot Net FrameWork 2.0 Installed on your computer
Get Windows PowerShell.
It's free, you'll need a genuine Windows Onyl
Download it Now !
http://www.microsoft.com/downloads/details.aspx?FamilyID=6ccb7e0d-8f1d-4b97-a397-47bcc8ba3806&displaylang=en&Hash=P5efSRc1EO%2bOJ5g%2bKKEh0W4Be1L3cWlbvzTi6GGNkWAec0nKpQlNKKlBdtUNUGCbatCsnzMUquumPR3dXY5hrw%3d%3d

Number to Hex and vice versa

With VB6 and older version, it was quite hard to do this conversion. But now I'll show you a small function that will solve the whole problem.
The new Hex Function
First make a new form with a Text Box and a button
Then place the following code in the button (onclick())
MsgBox(Hex(TextBox1.Text))
Now run the application and tape some numbers in the textbox and press the button.
A message box will give you the Hex value !
Vice Versa ;)
Here's a very nice class of functions for conversion (Convert.)
We'll use the Convert.ToInt32. But this is a little more complexed. We'll add a new thing, here you'll need to define the Base
For Hexadecimal, the base is : 16
So place the following code
MsgBox(Convert.ToInt32(TextBox1.Text, 16))
Hope it helps some of you !
Question ? Post a comment

Data Conversion in Visual Basic

If option strict is on, so you'll need explicit conversion (from string to integer, vice versa and so on)
I found this table in MSDN library and I think it will be helpful for you
CBool
Any valid Char or String or numeric expression.
CByte
0 through 255 (unsigned); fractional parts are rounded.
CChar
Any valid Char or String expression; only first character of a String is converted; value can be 0 through 65535 (unsigned).
CDate
Any valid representation of a date and time.
CDbl
-1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values.
CDec
+/-79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers, that is, numbers with no decimal places. For numbers with 28 decimal places, the range is +/-7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001 (+/-1E-28).
CInt
-2,147,483,648 through 2,147,483,647; fractional parts are rounded.1
CLng
-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807; fractional parts are rounded.
CObj
Any valid expression.
CSByte
-128 through 127; fractional parts are rounded.
CShort
-32,768 through 32,767; fractional parts are rounded.
CSng
-3.402823E+38 through -1.401298E-45 for negative values; 1.401298E-45 through 3.402823E+38 for positive values.
CStr
Returns for CStr depend on the expression argument.
CUInt
0 through 4,294,967,295 (unsigned); fractional parts are rounded.
CULng
0 through 18,446,744,073,709,551,615 (unsigned); fractional parts are rounded.
CUShort
0 through 65,535 (unsigned); fractional parts are rounded.

Option Explicit, Strict and Compare

Option are strange for begineer programers. And when I first programed, it seemed to me that they are very hard to understand. First Options come in the Top on any any thing in your code except comment.
When understanding what each option do, you'll see : very easy and funny. Let's start by Option Explicit

Option Explicit :

Let say you have the following code

Dim x as integer
x = 2

* The code Compile in all cases *
But

x = 2

* The code doesn't compile but may compile *

Here the aim, When Option explicit is on it forces explicit declaration of all variables in your code, but if you disble it you may don't declare you variable.
By default Option Exlicit is On

Option Strict :
Option Strict On
Dim X as string = "5"
Dim Y as integer
Y = X * This code doesn't compile *
But if "Option Strict Off" the code compile.
So Option Strict Restricts implicit data type conversions and "IMPLICIT" so here's how to do when Option Strict is On
Option Strict On
Dim X as string = "5"
Dim Y as integer
Y = Cint(X) * This code compile *
Cint(object) make an explicit conversion to Integer which is obligatory when Option Strict is On

Option Compare (Text/Binary)
Binary
Optional. Results in string comparisons based on a sort order derived from the internal binary representations of the characters.
Text
Optional. Results in string comparisons based on a case-insensitive text sort order determined by your system's locale.

This is what we call (Case Sensitive) without entring you in big stories :
Option Compare Text : A = a (Equal)
Option Compare Binary : A # a (Not Equal)
Option Compare Text
msgbox (a=A) 'Return True
Option Compare Binary
msgbox (a=A) 'Return False

Hope this helped you ! If you have question leave a comment ;)

Windows Defender


Windows Defender
This is again a free and powerful product from Microsoft. Windows Defender is a free Anti-Virus and protection system.
You can download it here : http://go.microsoft.com/fwlink/?LinkID=70604
Why Windows Defender is better ?
What I found good on Windows defender is that he control Registy settings. So he alerts you if any program tried to add or delet registry keys and have the ability to deny it.
Another nice thing is the software explorer, that will help you to identify running program, Network Connected program, Winsock service provider and startup programs.
Screen Shoot of Software Explorer

Windows Defender have also a list of definition of viruses and can make full scannes for your computer.
So I advice you to use Windows Defender, you need only to have a Windows Genuine (With Pirated windows you can't download it form Microsoft)
See http://go.microsoft.com/fwlink/?LinkID=70604 for more information about Windows Defender

WMI (Windows Managment Instrument)

WMI (Windows Managment Instrument)
This is how Windows and Win32Api application works.
All are based on the WMI.
The WMI return ALL Computer, devices and Windows Information. Most of you (I think know how to use it)
But the problem still of how to know it's classes
I'll give you the code of how to use it :
First of all add the System.Managment Reference and Imports it "Imports System.Management"
Dim info As Management.ManagementObject
Dim search1 As New Management.ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
For Each info In search1.Get()
MsgBox info("Name").ToString()
Next
The following function will return the Operating System Name stored in the Managment Instrument of Windows.
Now the problem that most of developers face, is how to find the classes.
I found here a solution given by Roman, Anima Online Hardware Monitor.
It's let's you find all of them and even do query, this will fast you work !
Find it @ : http://animaonline.blogspot.com/2007/03/animaonline-hardware-monitor-10.html

Multi-Threading with Windows Forms Control

This problem will happen to anyone that uses threads. When trying to call a Form control from a Thread, the debugger raises an InvalidOperationException with the message, "Control control name accessed from a thread other than the thread it was created on."
Why Microsoft add this feature in VS 2005 ?
When it's enabled (you can manipulated control through threads), it is possible to force the control into an inconsistent state when it's controled by more than one thread.
So you can Disable this feature simply by adding this line of code :
CheckForIllegalCrossThreadCalls = false
Where to add ?
Open the Form Designer and put this line in the Private Sub InitializeComponent()
I get this idea from Anima Blog, http://animaonline.blogspot.com/2007/09/fixing-cross-thread-operation-not-valid.html

Aîd Mabrouk

Tomorrow (Friday 12 October 2007), We'll celebrate the Aîd in the arabic and all islamic countries
So I wish every hapiness in this day for all muslims

Free Barcode Creator

Barcode Maker 2.0 is ready with many new features
http://barcodemaker.freehostia.com
No Need to Purchase Expensive Barcode creator Software when it is Totally Free.

Barcodemaker Features :

Supports Code 3 of 9
Code 128
Interleaved 2 of 5
EAN-8
EAN-13
Customize print size
New => Print many barcode in a page with our Tabling System
New => Add title, border and comment to your Barocde
New => Real Time analyzing your code

Add-in to work with Office and other editors
New => Export to any image Format (Gif, JPEG...) ==> NEW !!
Export also to RTF and HTML Format

Requirements :

.net Frame Work 2.0
size : less than 0.5 mb (190 KB on download)
Microsoft .net FrameWork 2.0: Download here
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en

Compatible with any editor that supports True Type Font

http://barcodemaker.freehostia.com

ADO.NET : Connecting to a Data Provider

The following set of statements establishes a connection to a SQL Server Express database named MyDatabase running on the system named MySystem, using the active Microsoft Windows login account for its security access:

Dim theDatabase As System.Data.SqlClient.SqlConnection
Dim connectionString As String = _
"Data Source=MySystem\SQLEXPRESS;" & _
"Initial Catalog=MyDatabase;Integrated Security=true"

theDatabase = New SqlClient.SqlConnection(connectionString)
theDatabase.Open( )
' ---- Perform database processing here, then…
theDatabase.Close( )
theDatabase.Dispose( )



ADO.NET includes several different database libraries. The most generic library, found in the System.Data namespace, defines the core classes used to manage database sets in memory. There are distinct classes for tables, columns, and rows of data; classes that let you establish relationships between the tables; and classes that let you bundle tables and relationships in one large "data set." You will probably use these classes quite a bit in your code, but they know nothing of database connections or how to communicate with any external data source (other than specially formatted XML files).

To connect a provider to a data source, you create a connection object using a valid connection string and then use the Open() method to establish the connection. ADO.NET connection strings are similar to those used in OLE DB and ADO, and building them can be tricky. Connection strings are semicolon-delimited sets of connection parameters, with each entry taking the form parameter=value. The choice of parameters and values varies by connection type and desired features. The connection string used here includes three parameters (DataSource, InitialCatalog, and Integrated Security):

Data Source=MySystem\SQLEXPRESS;Initial Catalog=MyDatabase;
Integrated Security=true



Setting Integrated Security to true tells SQL Server to use the current Windows user's authentication information to connect to the database. If your database uses SQL Server's built-in authentication system, you can use the following connection string (for user "sa" and password "abc"):

Data Source=MySystem\SQLEXPRESS;Initial Catalog=MyDatabase;
User ID=sa;Password=abc



Each provider includes a " connection string builder class" (it's found at System.Data.SqlClient. SqlConnectionStringBuilder for the SQL Server provider), and although you can use it, it is simply a string-concatenation tool that attaches the semicolon-delimited parts you provide. You still need to know what each of the parameters and values should be.

The documentation installed with Visual Studio includes an article named "Working with Connection Strings" that includes common parameter names and values. If you look in the online help index for "connection strings [ADO.NET]," the "Working with Connection Strings" article is one of the results. For Oracle connection strings using Oracle's own provider, consult your Oracle documentation or their web site.

Once you have a valid connection string, use it as an argument to the connection object's constructor:

Dim theDatabase As System.Data.SqlClient.SqlConnection
Dim connectionString As String = _
"Data Source=MySystem\SQLEXPRESS;" & _
"Initial Catalog=MyDatabase;Integrated Security=true"
theDatabase = New SqlClient.SqlConnection(connectionString)



Establish the connection by using the Open() method:

theDatabase.Open()



You don't need to close the connection until you are truly finished interacting with the database. When you use the Open() method, ADO.NET opens the connection only long enough to verify the connection. It then closes the connection, waiting for you to issue a SQL statement before it opens the connection again.

When you are really ready to close the connection, use the Close() method:

theDatabase.Close()



To make your connection string see the site http://www.connectionstrings.com provides many useful examples of ADO.NET connection strings

Win32Api Class

This is a sample of Win32Api Classes

Class found on Developer Fusion

''''''''''Declare API "Calls"''''''''''''''''''''''''''''''''
Public Declare Function GetDriveType Lib "kernel32" _
Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer

Declare Function SwapMouseButton Lib "user32.dll" _
Alias "SwapMouseButton" (ByVal bSwap As Integer) As Integer

Public Declare Function DeclareBeep Lib "kernel32" Alias "Beep" _
(ByVal dwFreq As Integer, ByVal dwDuration As Integer) As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub btnUserName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUserName.Click
'Display a message box with the name of the current user

Dim strUserName As String = Environment.ExpandEnvironmentVariables("%username%")
MessageBox.Show("The current user of the computer is: " & strUserName, "UserName")
End Sub

Private Sub btnComputerName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComputerName.Click
'Display a message box with the name of the computer

Dim strComputerName As String = Environment.ExpandEnvironmentVariables("%ComputerName%")
MessageBox.Show("The current computer name is: " & strComputerName, "ComputerName")
End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'Exit the program

Me.Close()
End Sub

Private Sub btnGetMouseX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMouseX.Click
'Display the verticle position of the cursor

lblMouseX.Text = Windows.Forms.Cursor.Position.X
End Sub

Private Sub btnGetMouseY_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMouseY.Click
'Display the horizontal position of the cursor

lblMouseY.Text = Windows.Forms.Cursor.Position.Y
End Sub

Private Sub btnDriveType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDriveType.Click
'Display the Drive type for the Drive letter they entered

Dim strMyDrive As String
strMyDrive = txtDrive.Text + ":\"

Select Case GetDriveType(strMyDrive)
Case 2
MessageBox.Show("Drive type: Removable")
Case 3
MessageBox.Show("Drive type: Fixed")
Case Is = 4
MessageBox.Show("Drive type: Remote")
Case Is = 5
MessageBox.Show("Drive type: Cd-Rom")
Case Is = 6
MessageBox.Show("Drive type: Ram disk")
Case Else
MessageBox.Show("Drive type: Unrecognized")
End Select
End Sub

Private Sub btnSwapMouse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSwapMouse.Click
'Switch the left and right mouse buttons

SwapMouseButton(1)
End Sub

Private Sub btnResetMouse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResetMouse.Click
'Restore the normal mouse button settings

SwapMouseButton(0)
End Sub

Private Sub frmAPI_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
'If they wanted to switch thier mouse back on exit, then do it

If chkNormalMouseOnExit.Checked = True Then
'Normalize the mouse
SwapMouseButton(0)

MessageBox.Show("You mouse settings are now 'normal'.", "Mouse settings", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub trkBeepLength_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles trkBeepLength.ValueChanged
'Show the user they select for 'Beep Length'

lblBeepLength.Text = "Beep Length: " & trkBeepLength.Value * 100
End Sub

Private Sub trkBeepFreq_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles trkBeepFreq.ValueChanged
'Show the user they select for 'Beep Frequency'

lblBeepFreq.Text = "Beep Frequency: " & trkBeepFreq.Value * 100
End Sub

Private Sub btnBeep_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBeep.Click
'Beep with the chosen settings

DeclareBeep(trkBeepFreq.Value * 100, trkBeepLength.Value * 100)
End Sub



The Microsoft Class


' Copyright (c) Microsoft Corporation. All rights reserved.
Imports System.Runtime.InteropServices
Imports System.Text
' Class to wrap up Windows 32 API constants and functions.
Public Class Win32API
_
Public Structure OSVersionInfo
Public OSVersionInfoSize As Integer
Public majorVersion As Integer
Public minorVersion As Integer
Public buildNumber As Integer
Public platformId As Integer
_
Public versionString As String
End Structure

_
Public Structure SECURITY_ATTRIBUTES
Public nLength As Integer 'dword
Public lpSecurityDescriptor As Integer 'lpvoid
Public bInheritHandle As Integer 'bool
End Structure

Public Const GWL_EXSTYLE As Integer = (-20)
Public Const GW_OWNER As Integer = 4
Public Const SW_RESTORE As Integer = 9
Public Const SW_SHOW As Integer = 5
Public Const WS_EX_TOOLWINDOW As Integer = &H80
Public Const WS_EX_APPWINDOW As Integer = &H40000

Public Declare Function CreateDirectory Lib "kernel32" _
Alias "CreateDirectoryA" (ByVal lpPathName As String, _
ByRef lpSecurityAttributes _
As SECURITY_ATTRIBUTES) As Boolean


Public Delegate Function EnumWindowsCallback(ByVal hWnd As Integer, _
ByVal lParam As Integer) As Boolean

Public Declare Function EnumWindows Lib "user32.dll" _
Alias "EnumWindows" (ByVal callback As EnumWindowsCallback, _
ByVal lParam As Integer) As Integer

CharSet:=CharSet.Ansi, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EnumWindowsDllImport(ByVal callback As EnumWindowsCallback, _
ByVal lParam As Integer) As Integer
End Function

Public Declare Auto Function FindWindow Lib "user32.dll" _
Alias "FindWindow" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Integer

Public Declare Auto Function FindWindowAny Lib "user32.dll" _
Alias "FindWindow" (ByVal lpClassName As Integer, _
ByVal lpWindowName As Integer) As Integer

Public Declare Auto Function FindWindowNullClassName Lib "user32.dll" _
Alias "FindWindow" (ByVal lpClassName As Integer, _
ByVal lpWindowName As String) As Integer

Public Declare Auto Function FindWindowNullWindowCaption Lib "user32.dll" _
Alias "FindWindow" (ByVal lpClassName As String, _
ByVal lpWindowName As Integer) As Integer


Public Declare Function GetClassName Lib "user32.dll" _
Alias "GetClassNameA" (ByVal hwnd As Integer, _
ByVal lpClassName As StringBuilder, _
ByVal cch As Integer) As Integer

Public Declare Function GetDiskFreeSpace Lib "kernel32" _
Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _
ByRef lpSectorsPerCluster As Integer, _
ByRef lpBytesPerSector As Integer, _
ByRef lpNumberOfFreeClusters As Integer, _
ByRef lpTotalNumberOfClusters As Integer) As Integer


Public Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, _
ByRef lpFreeBytesAvailableToCaller As Integer, _
ByRef lpTotalNumberOfBytes As Integer, _
ByRef lpTotalNumberOfFreeBytes As UInt32) As Integer

Public Declare Function GetDriveType Lib "kernel32" _
Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer

Public Declare Function GetParent Lib "user32.dll" _
Alias "GetParent" (ByVal hwnd As Integer) As Integer


Declare Ansi Function GetVersionEx Lib "kernel32.dll" _
Alias "GetVersionExA" (ByRef osvi As OSVersionInfo) As Boolean

Public Declare Function GetWindow Lib "user32.dll" _
Alias "GetWindow" (ByVal hwnd As Integer, _
ByVal wCmd As Integer) As Integer

Public Declare Function GetWindowLong Lib "user32.dll" _
Alias "GetWindowLongA" (ByVal hwnd As Integer, _
ByVal nIndex As Integer) As Integer

Public Declare Sub GetWindowText Lib "user32.dll" _
Alias "GetWindowTextA" (ByVal hWnd As Integer, _
ByVal lpString As StringBuilder, _
ByVal nMaxCount As Integer)

Public Declare Function IsIconic Lib "user32.dll" _
Alias "IsIconic" (ByVal hwnd As Integer) As Boolean

Public Declare Function IsPwrHibernateAllowed Lib "Powrprof.dll" _
Alias "IsPwrHibernateAllowed" () As Integer

Public Declare Function IsWindowVisible Lib "user32.dll" _
Alias "IsWindowVisible" (ByVal hwnd As Integer) As Boolean

Public Declare Function SetForegroundWindow Lib "user32.dll" _
Alias "SetForegroundWindow" (ByVal hwnd As Integer) As Integer

Public Declare Function SetSuspendState Lib "Powrprof.dll" _
Alias "SetSuspendState" (ByVal Hibernate As Integer, _
ByVal ForceCritical As Integer, _
ByVal DisableWakeEvent As Integer) As Integer

Public Declare Function ShowWindow Lib "user32.dll" _
Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer

Declare Function SwapMouseButton Lib "user32.dll" _
Alias "SwapMouseButton" (ByVal bSwap As Integer) As Integer

End Class

Sorting Numbers

How to Organise Numbers.
Numbers, we all know but how to organise... It's quite Simple.
Very easy sample of how to sort numbers (of an array).

This part sort from Small to Big

// First you need a simple Form and then place a button
// Declaration in the Form Class
Dim A(20) As Integer
Dim num, i, j, k, arr, temp As Integer
// And this is what will start all
Private Sub Command1_Click()
arr = 0
msgbox "Your array contains: "
For k = 0 To num - 1
msgbox "A" & "(" & arr & "):" & A(k)
arr = arr + 1
Next k
End Sub
// To make some starting put this in the FormLoad
Private Sub Form_Load()
num = InputBox("Intialize the size of your array:")
For i = 0 To num - 1
A(i) = InputBox("Enter your array: ")
Next i

'this will sort your array in ascending order
For i = 0 To num - 1
For j = i + 1 To num - 1
If A(i) > A(j) Then
temp = A(i)
A(i) = A(j)
A(j) = temp
End If
Next j
Next i

End Sub

// In the Reverse Sense.
// Won't explain now I think you know the basics
Dim A(20) As Integer
Dim num, i, j, k, arr, temp As Integer
Private Sub Command1_Click()
arr = 0
msgbox "Your array contains: "
For k = 0 To num - 1
msgbox "A" & "(" & arr & "):" & A(k)
arr = arr + 1
Next k
End Sub
Private Sub Form_Load()
num = InputBox("Intialize the size of your array:")
For i = 0 To num - 1
A(i) = InputBox("Enter your array: ")
Next i

'this will sort your array in descending order
For i = 0 To num - 1
For j = i + 1 To num - 1
If A(i) < A(j) Then
temp = A(i)
A(i) = A(j)
A(j) = temp
End If
Next j
Next i

End Sub

// when compilation..
An input box will ask for the array length.
Then you'll be asked for each numbers
Sorted and displayed Msgbox by Msgbox

Datagridview

The DataGridView control

I found many programers interested about using the Data Grid View, so I made this small tutorial about it.
I'm going to show how to use the Data Grid View independently of a data base. I'll show the best methods that I found while reading and learning about the datagridview control. And I'll also wait for your comments or questions.
In this part I'll explain how to use it with the datagridview and put data on it with the datagridview.datasource using an array and a class.
Understanding the DGV Data Source :
First let's return to a DGV when it's related to a data base or how to relate it.
Simply we use the following code : datagridview.datasource = BindingSource
So the datagridview get the appearence (Columns name) and the data (rows) from the binding source and put it in the datagridview.datasource
But the datagridview don't accept only one type of datasources but many and this will help us to customize it.
Now open a new project and create a new form and place a new datagridview.
Now make a new button and double click to put code on it.
Let's think about what kind of data the datagridview can accept. String (it's impossible) and also integer. But if you try to put a string or integer on the datagridview datasource you won't get an error but simply nothing (and for me that's worth, because when you don't get error you don't know where the problem is!!)
So why not array, arrays are like a table and the datagridview is a table
So put the following code on the button Click action

Dim arr() As String = _
{"a", "aa", "aaa"}
DataGridView1.DataSource = arr

And then run the application, when you'll click the datagridview will display a column "Length" and will give each string length. That's stupid 4 you but the datagridview need more presicion to understand your code.

So let's try more code :

First add the following class

Public Class DGV
Private _row As String
Public Sub New(ByVal row As String)
_row = row
End Sub

Public Property Column() As String
Get
Return _row
End Get
Set(ByVal value As String)
_row = value
End Set
End Property
End Class

and then put the following code on the button click action

Dim arr() As DGV = { _
New DGV("Row 1"), _
New DGV("Row 2"), _
New DGV("Row 3")}
DataGridView1.DataSource = arr

The following code will made a new column in the datagridview named column (the same name as the property name)
You can make rows as much as you want just in the DGV array add a new "New DGV("Whatever you want")"
Now we can make a column and put data on it. So let's advance more.
First you won't use this class as it but you have to customize it for your need.

Public Class DGV
Private _name As String
Private _ID As String

Public Sub New(ByVal id As String, ByVal name As String)
_ID = id
_name = name
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property

Public Property ID() As String
Get
Return _ID
End Get
Set(ByVal value As String)
_ID = value
End Set
End Property
End Class

And then. First let's tune the columns numbers. See the public property. We have in this class 2 public property. This means that we'll get 2 columns. If you want more columns then add a new public property. The public property name is important because (as the previous example) it will be the column name.
Now, if you are going to add a column then add a new public property and choose a new for it, for example "comment" then add a new private string (or integer as you like) To be organised name the string _comment, so then it'll be much colmuns you won't get lost.
Now let's move on to the public property.
Add a Get block and put on it Return _comment
Add a Set block (Byval value as String) and put _comment = value
Finally in the new sub put _comment = comment
And then we made a new column.
NB : Very important, the column order depend on the public property order ! We made name then Id then we'll get a datagridview with "name"id" as the order of the class.
Now let's move to the button that we'll use the DGV class to put the data.

Dim arr() As DGV = { _
New DGV("Row 1", "more"), _
New DGV("Row 2", "more"), _
New DGV("Row 3", "more")}
DataGridView1.DataSource = arr

Now let's analyze the following code
New DGV (property1,property2),_
New DGV (property1,property2),_
.....
Very important!! if you have 2 column as in this sample then you musty enter 2 property, if you have 3 column then you must enter 3 property.
If you forget one this will become an error.

Don't forget to comment or suggest if I missed somethings

Visual Studio 2008 Orcas

I have about 2 months testing the Orcas and I wanted to mention to new features that attracts my attention and it seems that they can be interesting
The new version is already in Beta 2, you can download the Express edition for free from the Microsoft site.
What's new VS 2005 ?
I'm going to mention only the most important features that where add to this new version.
LINQ : (Langauge Integrated Query)
This new (it's a set of library class) code name is interesting only for SQL Developer.
LINQ will replace the SQL Query language (that is unfamiliar especially for who program with SQL for the first time) with a native language for queries and provides class libraries to take advantage of these capabilities. So new developers don't have to learn the SQL query language but only to know this easy to use classes.

This may be no so interesting for most of programers (LINQ) but WPF is!!!
WPF (Windows Presentation Foundation) is a new model of forms! It will allow you to make high quality forms and very nice design.
WPF is different then the normal Windows forms. The new orcas offers new tools that allow you to design your forms (trace lines,cercles..) the buttons and check boxes are more customizable and you can change the look of object. This thing was missing (Easy Design) especially on the 6 version.
Microsoft now ta ke care of design as much as code ease.
I found a nice example of WPF made by Martin Grayson, a very nice Glass Button. You can found it in his blog http://blogs.msdn.com/mgrayson
Hope it interest some of you to change to the new ORCAS and I'm going to make more articles about it

Summer Analytics

Summer Analytics

This Summer Analytics that I collected just to give information of how much I use computer and on which things

Number Of Hours (Using Computer) : 756 Hour
Pourcentage of Internet Use : 64.4 %
Pourcentage of Programming Use : 32.9 %
Other : 2.9 %

Internet Use : (With Google Counter)
Number Of Page Visited : 362.521
Most Active Sites I was Surfing :
1/ Google (Gmail, Groups, Analytics, Adsense...)
2/ Microsoft (Technet, MSDN, Forums, Live...)
3/ Source Forge

Programing :
Number Of program made : 2
Number Of Lines Code : 9652 Line (vb.net, PHP, Asp)