Wednesday, December 21, 2005

VB.NET 2005 :)

Quoted From Ken Getz MCW Technologies, LLC - MSDN

The My Namespaces

Imagine being able to find the functionality you need within the huge set of classes available as part of the .NET Framework immediately. Imagine using a single reference to accomplish goals that would otherwise require many lines of code. Imagine being more productive than you could ever have been programming in previous versions of Visual Basic or Visual Basic 6. These goals, and more, have been met with the addition of the My namespace to Visual Basic 2005.

Like shortcuts on your Windows desktop make it easier for you to find the applications and files you need in Windows, the My namespace classes provide shortcuts to commonly used functionality within the .NET Framework. In addition, the My namespace adds functionality that was previously difficult to find, difficult to use, or was simply not possible without unmanaged API calls.

The My namespace includes the following classes, each of which includes a number of useful members:

* Application

* Computer

* Forms

* Resources

* Settings

* User

For example, to play an audio file in Visual Basic 2005, rather than using DirectX or Win32 API calls, you could write this simple single line of code:

My.Computer.Audio.Play("C:\Beep.wav")

Or, to play a system sound, you might write code like this:

My.Computer.Audio.PlaySystemSound(SystemSounds.Asterisk)

In addition, My namespace supplies functionality that otherwise requires substantial code. For example, the following code demonstrates how you can use simple code to ping a computer:

If My.Computer.Network.IsAvailable Then If My.Computer.Network.Ping("http://www.microsoft.com") Then MsgBox("Microsoft's site is available.") End If End If

Working with the file system has never been easier. My.Computer.FileSystem provides a flat, stateless, discoverable, and easy-to-use way to perform common file system operations. File system operations such as copying, deleting, moving, and renaming files and folders are at the core of My.Computer.FileSystem. For example, developers frequently require file, folder, and drive properties (such as a file's size, encoding, and so on). Using My.Computer.FileSystem, commonly referenced file, folder, and drive properties can be obtained easily. For example, to display the size of each drive in your system, you might write code like the following:

For Each drv As DriveInfo In My.Computer.FileSystem.Drives If drv.IsReady Then Debug.WriteLine(String.Format( _ "{0}:\ {1:N0}", drv.Name, drv.TotalSize)) End If Next

The My.User class provides information about the current user, including Name and IsInRole properties. You could use code like the following to display the current user's information and whether the user is an administrator:

MsgBox(My.User.Identity.Name & ":" & _ My.User.IsInRole("Administrators"))

If you wanted to determine the current user's application data folder, you could use simple code like the following:

MsgBox( _ My.Computer.FileSystem.SpecialDirectories. _

CurrentUserApplicationData)

The My namespace also adds functionality that returns many of the RAD features of Visual Basic 6 to the .NET development platform. For example, Visual Basic developers historically accessed forms by name, relying on the runtime engine to maintain a collection of all the available form classes. Using the new My.Forms collection, developers can write code to open and interact with an instance of a form class created as part of a solution, like the following:

My.Forms.HelpForm.Show()

In addition, the My namespace includes a number of other dynamically created collections, including Forms, WebServices, Resources, and Settings. The My.WebServices collection allows developers to easily call Web Service methods taking advantage of IntelliSense and strong typing, and makes the call simpler as well. For example, imagine a Web Service named Numbers that has already been declared in a project. Calling the NumToStr method of the Web Service couldn't get much easier than this:

MsgBox(My.WebServices.Numbers.NumToStr(123.45))

The My namespace has been devised to make it simpler for Visual Basic developers to accomplish their goals with less work, and with less searching through multiple namespaces. You'll find that many arduous tasks in previous releases are now only a single reference away.

Friday, December 09, 2005

ACM 28/11/2005 KUWAIT

The ACM competition which took place in Kuwait this year was an amazing event and one of the interested events I have participated ever. I was one of the contestants who have to solve the 10 problems in order to join the International contest which will take place in USA this year. My team called (Show the way) and our goal was to solve 5 problems at least we were training for 4 months ago but in the end we passed with two problems which were bad for us and prevent us even from being ranking as the 13th winner team. Actually it wasn't regarding we don't have enough knowledge to solve more cause we trained so fine but it was all about the experience of participating. We enjoyed there by meeting a lot of competitors from different parts of our Arab world which heats up the passion to participate and compete more and more. They all joined with passion for winning but Egypt was the better due to its experience (4 years) :S. Hopefully I will do better in the next programming contests. I wished for my team to win the battle but defiantly we still need more experience about how to feel confidence in participating like these contests. Anyway I hope the next times will allow me to show them the programming creation that I hopefully have ;) .

I'm on the way to participate with the Imagine Cup 2006 contest will I have do much better to gain the experience and the Cup nothing is impossible if you did hard !!!.