Thursday, February 19, 2015

10 Reasons Why Visual Basic is Better Than C#

10 Reasons Why Visual Basic is Better Than C#

07 March 2012
After having converted a whole lot of training materials based on VB.NET into C#, Andy ‘Wise Owl’ Brown decided to write a tongue-in-cheek rant whilst he could still remember the pain-points. 'Convert to VB.NET! You have nothing to lose but your semi-colons! '
Visual Basic is a better programming language than Visual C#. Who says so? This article! Here are 10 reasons why you should always choose VB over C#.

1 – “Rose is a rose is a rose is a rose”

This is a quotation from Gertrude Stein’s 1922 play Geography and Plays. However, the poetry wouldn’t work in C#, because – unforgivably – it’s a cASe-SeNSitIvE language. This is madness!
Before I start ranting, let me just acknowledge that case-sensitivity confers one (and only one) advantage – it makes it easier to name private and public properties:
Writing properties like this means that you can refer to the public Name property, and it’s obvious what the private equivalent will be called (name).
// private version of variableprivate string name = null;public string Name
{
    get
    {
        return txtName.Text;
    
}
    set
    {
        name txtName.Text;
    
}
}
So now we’ve got that out of the way: case-sensitive programming languages make everything else harder. Why, you ask?
  • You keep having to switch between upper and lower case when typing, causing RSI in your poor little fingers as you reach for the inconsiderately located Shift key.
  • You are much more likely to make mistakes - are you sure you meant to type DateOfBirth, or should it have been dateofbirth?
  • When you accidentally leave Caps lock on, it really matters.
The only possible benefit is that you can use more combinations of variable names, that is, you can use more of one of the few infinite resources in this universe…
It doesn’t matter if you disagree with everything else in this article: case-sensitivity alone is sufficient reason to ditch C#!

2 – The Switch clause

Both VB and C# contain a way of testing mutually exclusive possibilities, the Select Case and Switch clauses respectively. Only one of them works properly.
A Visual Basic Select Case clause, returning a description of how old someone is. The age range for a young person is a tad generous, reflecting the age of the author of this article.
A Visual Basic Select Case clause, returning a description of how old someone is. The age range for a young person is a tad generous, reflecting the age of the author of this article.
Select Case AgeEntered

    Case Is 18
        txtVerdict.Text "child"
    
Case Is 50
        txtVerdict.Text "young person"
    
Case Is 65
        txtVerdict.Text "middle-aged"
    
Case Else
        
txtVerdict.Text "elderly"
End Select
You can’t do this using Switch in C#, as - astonishingly - it can’t handle relational operators. You have to use an If /Else If clause instead. But even if you could, you’d still have to type in lots of unnecessary Break statements:
switch (AgeThreshold{
    case 18 :
        
txtVerdict.Text "child";
        
break;
    
case 50 :
        
txtVerdict.Text "young person";
        
break;
    
case 65 :
        
txtVerdict.Text "middle-aged";
        
break;
    
default:
        txtVerdict.Text "elderly";
        
break;}
 
It’s easy to forget to type in each of theseBreak statements!

3 – Event-Handling code

This is specific to Visual Studio (I’m using 2010, the latest version). Suppose I want to attach code to anything but the default Click event of a typical button:
Selecting the button
Let’s suppose that I want to attach code to the MouseHover event of this button.
I can do this in Visual Basic without leaving the code window:
a) First choose the object from the drop list.
Attaching the Mousehover code
Choosing the event to code
b)Then choose the event you want to code.
In C# you can’t do this – you have to return to the button’s properties window and choose to show its events:
Selecting the event in C#
You can double-click to attach code to this event for the selected button – but that’s the only simple way to create it for C#.
But it’s even worse than that. If you then rename a control (in this case btnApply) you have to re-associate the event-handler with the renamed control in the properties window (or in the initialisation code, if you can find it). In Visual Basic, of course, you can do all of this in code:
    Private Sub btnApply_Click(ByVal sender AsSystem.Object,
        ByVal e As System.EventArgsHandles btnApply.Click

        MessageBox.Show("Hello")

    End Sub
Globally change btnApply to the new button’s name in code, and everything will work as before.

4 –Stupid symbols

C# was written by academics. It shows. Consider this table of C# symbols and their VB equivalents:
What you're trying to doC# SymbolVB Equivalent
Test if two conditions are both true&&and
Test if one or other condition is true||or
Test if a condition is not true!not
Concatenate two strings of text+&
Test if a condition is true within an if statement===
Which column looks like it was designed by a real person?

5 – Autocorrection in Visual Basic actually works

IntelliSense works much better for Visual Basic than for Visual C#. Take just one example – creating a write-only property. Let’s start with Visual Basic:
When you press return at the line end…
    WriteOnly Property PersonName As String
        Set(value As String)

        End Set
    End Property
… You get this fully-completed clause.
For C#, the same thing doesn’t happen:
When you press return here, nothing happens (other than a blank line appearing).
This is just one example. I’ve just spent ages transcribing our VB courses into C#, and believe me, there are many, many more!

6 – Lack of supported functions

Here are a couple of functions I use from time to time in VB:
FunctionWhat it does
IsNumericTests if a value can be converted to a number
PMTCalculates the annual mortgage payment for a loan
Great functions, but they don’t exist in C#.

7 – That wretched semi-colon

Why do I have to end every line in C# with a semi-colon? The argument used to be that it avoided the need to use continuation characters in Visual Basic:
MessageBox.Show_
    text:="This article is a bit opinionated"_
    caption:="Message")
You used to have to use an underscore as a continuation character to show incomplete lines of code in VB.
However, as of Visual Basic 2010 you rarely need to do this anymore. Come on, C#: Visual Basic has ditched its line-ending character; why can’t you?(;)
Someone commented on my original (much shorter) blog about this:

    "In a short amount of time you'll type those semi-colons without thinking about it (I even type them when programming in visual basic)."

That’s like saying that you’ll soon get used to not having any matches to light your fire, and you’ll even start rubbing sticks together to start a fire when you finally manage to buy a box!

8 – Arguments and variables

The order of words in a C# variable declaration is wrong. When you introduce someone, you wouldn’t say, “This is my friend who’s a solicitor; he’s called Bob”. So why do you say:
string PersonName "Bob";
To me:
Dim PersonName As String = "Bob"
…is much more logical. I also find the C# method of having to prefix arguments with the word out confusing, particularly as you have to do it both in the called and calling routine.

9 – Strictness

C# is a much fussier language than Visual Basic (even if you turn Option Strict on in Visual Basic, this is still true). “And a good thing, too!”, I hear you cry. Well, maybe. Consider this Visual Basic code:
Enum AgeBand
   Child 18
   Young 30
   MiddleAged 60
   SeniorCitizen 90
End Enum



Select Case 
Age
    Case Is AgeBand.Child
        MessageBox.Show("Child")
    
Case Else
        
MessageBox.Show("Adult")End Select
With Option Strict turned on this shouldn’t really work, as it’s comparing an integer with an enumeration – but VB has the common sense to realise what you want to do.
The equivalent in Visual C# doesn’t work:
A less forgiving language…
What this means is that you end up having to fill your code with messy type conversions:
The simplest way of converting an enumeration to an integer; but why should you have to?
// find out the age enteredint Age Convert.ToInt32(txtAge.Text);
if (Age (intAgeBand.Child{
    MessageBox.Show("Child");else {
    MessageBox.Show("Adult");}

10 – Redimensioning arrays

If you want to dynamically change the length of an array in Visual Basic, you can use Redim Preserve. To do the same thing in Visual C#, you have to copy the array, add a value and then copy it back:
The vile, clunky C# method of extending an array.
string[] PartyGuests = new string[2];
PartyGuests[0] "Sarah Palin";PartyGuests[1] "Richard Dawkins";
// whoops! forgot to invite Mitt

// create a new extended array
string[] tempGuests = new string[PartyGuests.Length + 1];
// copy all of the elements from the old array into new oneArray.Copy(PartyGuests,tempGuests,PartyGuests.Length);
// add Mitt as last elementtempGuests[PartyGuests.Length] "Mitt Romney";
// restore full list into original arrayPartyGuests tempGuests;
// check worksforeach (string Guest in PartyGuests{
    System.Diagnostics.Debug.Write(Guest);}
 
This epitomises Visual C# for me. Critics will tell me that:
  • Behind the scenes, the Redim Preserve command does exactly the same thing as the C# code above; and
  • I should be using lists and not arrays anyway.
That’s hardly the point! The point is that - as so often - Visual Basic makes something easier to code than C# does.

Conclusion

So those are my 10 reasons to code in Visual Basic. What are you waiting for, all you C# code-monkeys? Convert all of your code to VB – you have nothing to lose but your semi-colons!
Andy Brown
Author profile: Andy Brown
Andy works as a trainer and consultant for Wise Owl Training, providing SQL Server, .NET, Visual Basic and (reluctantly!) C# training for businesses in the UK.

How To Recover Your Lost Passwords *****

How to determine which versions of the Microsoft .NET Framework are installed

How to determine which versions and service pack levels of the Microsoft .NET Framework are installed

Use the slipstream procedure to update SQL Server 2008

Use the slipstream procedure to update SQL Server 2008
This method allows you to update the entire product when you run the SQL Server 2008 Setup program after following one of the following procedures:
Procedure 1: Basic slipstream steps
Follow the following steps to create a slipstream drop that you can use for installing the original media and a service pack at the same time.
Install the following prerequisites for SQL Server 2008.
.NET Framework 2.0 SP2 for SQL Server 2008 Express Edition
You can obtain the .NET Framework 2.0 SP2 from the following Web site in Microsoft Download Center:
http://www.microsoft.com/downloads/details.aspx…
.NET Framework 3.5 SP1 for other editions
To download and install the .NET Framework 3.5 SP1, visit the following Microsoft Web site:
http://go.microsoft.com/fwlink/?LinkID=120550
Windows Installer 4.5
To download and install Windows Installer 4.5, visit the following Microsoft Web site:
http://go.microsoft.com/fwlink/?LinkID=49112
Download the service pack package that matches you system architecture. For example download the x64 package of SQL Server 2008 Service Pack 1 if your system is an x64-based system.
Extract the service pack by running the following command:
SQLServer2008SP1-KB968369-x64-ENU.exe /x:C:\SP1
Run the service pack to install Setup files on the computer. You will receive a Setup Support Files dialog box if the Setup support files have not been installed. You can also run the following file to install the setup support files:
C:\SP1\x64\setup\1033\sqlsupport.msi
Run the Setup.exe file from the SQL Server 2008 source media by specifying the /PCUSource parameter. For example:
Setup.exe /PCUSource=C:\SP1

Thanking you,
Best regards,
Udaysinh C. Vaghela
uday_oman@hotmail.com

Assign User Rights and Manage User Rights


User rights

Password Policy


Password Policy setting System as per IT and Microsoft Best Practice. •Please note that the password must respect the following rules • It must contain between 7 and 16 characters. • It must not contain your user name. •This security setting determines whether passwords must meet contain in 3 complex requirements, •Capital letter, Small letter, Number, Special letter •Use only characters from the following set: ! # $ % & ( ) * + , - . / 0123456789 : ; < = > ? @ ABCDEFGHIJKLMNOPQRSTUVWXYZ [ \ ] _ ` abcdefghijklmnopqrstuvwxyz { | } ~" • It must contain at least 1 letter(s) (ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)." • It must contain at least 1 numeric character(s) (0123456789). " • It must not contain more than 2 identical consecutive characters (AAA, iiii, $$$$$ ...). "

School Management System

School Management System

1. Admission and Evaluation
a. Requirements Check
2. Registration
a. New Students
a.1 Freshmen
a.2 Transferee
b. Old Students
c. Summer
3. Assessment
a. Full Payment
b. Installment
c. List of Payments
c.1 Tuition Fees
c.1.1 Discounts
c.1.2 Exemptions
c.2 Miscellaneous Fees
c.3 Other Fees
c.4 Additional Fees
4. Payments
a. Cash
b. Pay Cheque
c. Other Forms of Payment
5. Sectioning
a. Sectioning Modes
b. Re-Sectioning
a.1 Additional Sections
a.2 Removed Sections
6. Scheduling
a. Conflicts Overview
b. Teachers Program/Schedules
c. Subjects Schedules
d. Room Schedules
e. Student Schedules
f. Payment Schedules
g. SY Calendar
h. Notice of Payment Schedules
Additional Features:
1. Grading System
2. Accounts System
3. Cashiering System
4. Student Information System
5. Inquiry System
6. Bulk SMS Notification
If anyone interested to the system, feel free to contact me at uday_oman@hotmail.com, +968 99154460

How to get motherbord and hard disk serial no.

Domain name system. ( How to DNS Work? )

DNS - Domain Name System

(1) Short for Domain Name System (or Service or Server), anInternet service that translates domain names into IP addresses. Because domain names are alphabetic, they're easier to remember. The Internet however, is really based on IP addresses. Every time you use a domain name, therefore, a DNS service must translate the name into the corresponding IP address. For example, the domain name www.example.com might translate to198.105.232.4.
The DNS system is, in fact, its own network. If one DNS server doesn't know how to translate a particular domain name, it asks another one, and so on, until the correct IP address is returned.
(2) Short for digital nervous system,a term coined by Bill Gates to describe a network of personal computers that make it easier to obtain and understand information.

Dynamic Host Control Protocol.... What is DHCP?


Dynamic Host Configuration Protocol

What is DHCP? 


Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information such as the subnet mask and default gateway. RFCs 2131 and 2132 define DHCP as an Internet Engineering Task Force (IETF) standard based on Bootstrap Protocol (BOOTP), a protocol with which DHCP shares many implementation details. DHCP allows hosts to obtain necessary TCP/IP configuration information from a DHCP server.
The Microsoft Windows Server 2003 operating system includes a DHCP Server service, which is an optional networking component. All Windows-based clients include the DHCP client as part of TCP/IP, including Windows Server 2003, Microsoft Windows XP, Windows 2000, Windows NT 4.0, Windows Millennium Edition (Windows Me), and Windows 98.
Note
  • It is necessary to have an understanding of basic TCP/IP concepts, including a working knowledge of subnets before you can fully understand DHCP. For more information about TCP/IP, see “TCP/IP Technical Reference.”

Benefits of DHCP

In Windows Server 2003, the DHCP Server service provides the following benefits:
  • Reliable IP address configuration. DHCP minimizes configuration errors caused by manual IP address configuration, such as typographical errors, or address conflicts caused by the assignment of an IP address to more than one computer at the same time.
  • Reduced network administration. DHCP includes the following features to reduce network administration:

    • Centralized and automated TCP/IP configuration.
    • The ability to define TCP/IP configurations from a central location.
    • The ability to assign a full range of additional TCP/IP configuration values by means of DHCP options.
    • The efficient handling of IP address changes for clients that must be updated frequently, such as those for portable computers that move to different locations on a wireless network.
    • The forwarding of initial DHCP messages by using a DHCP relay agent, thus eliminating the need to have a DHCP server on every subnet.

Why use DHCP

Every device on a TCP/IP-based network must have a unique unicast IP address to access the network and its resources. Without DHCP, IP addresses must be configured manually for new computers or computers that are moved from one subnet to another, and manually reclaimed for computers that are removed from the network.
DHCP enables this entire process to be automated and managed centrally. The DHCP server maintains a pool of IP addresses and leases an address to any DHCP-enabled client when it starts up on the network. Because the IP addresses are dynamic (leased) rather than static (permanently assigned), addresses no longer in use are automatically returned to the pool for reallocation.
The network administrator establishes DHCP servers that maintain TCP/IP configuration information and provide address configuration to DHCP-enabled clients in the form of a lease offer. The DHCP server stores the configuration information in a database, which includes:
  • Valid TCP/IP configuration parameters for all clients on the network.
  • Valid IP addresses, maintained in a pool for assignment to clients, as well as excluded addresses.
  • Reserved IP addresses associated with particular DHCP clients. This allows consistent assignment of a single IP address to a single DHCP client.
  • The lease duration, or the length of time for which the IP address can be used before a lease renewal is required.
A DHCP-enabled client, upon accepting a lease offer, receives:
  • A valid IP address for the subnet to which it is connecting.
  • Requested DHCP options, which are additional parameters that a DHCP server is configured to assign to clients. Some examples of DHCP options are Router (default gateway), DNS Servers, and DNS Domain Name. For a full list of DHCP options, see “DHCP Tools and Settings.”

Terms and Definitions

The following table lists common terms associated with DHCP.
DHCP Terms and Definitions

 

TermDefinition
DHCP server
A computer running the DHCP Server service that holds information about available IP addresses and related configuration information as defined by the DHCP administrator and responds to requests from DHCP clients.
DHCP client
A computer that gets its IP configuration information by using DHCP.
Scope
A range of IP addresses that are available to be leased to DHCP clients by the DHCP Server service.
Subnetting
The process of partitioning a single TCP/IP network into a number of separate network segments called subnets.
DHCP option
Configuration parameters that a DHCP server assigns to clients. Most DHCP options are predefined, based on optional parameters defined in Request for Comments (RFC) 2132, although extended options can be added by vendors or users.
Option class
An additional set of options that can be provided to a DHCP client based on its computer class membership. The administrator can use option classes to submanage option values provided to DHCP clients. There are two types of options classes supported by a DHCP server running Windows Server 2003: vendor classes and user classes.
Lease
The length of time for which a DHCP client can use a DHCP-assigned IP address configuration.
Reservation
A specific IP address within a scope permanently set aside for leased use by a specific DHCP client. Client reservations are made in the DHCP database using the DHCP snap-in and are based on a unique client device identifier for each reserved entry.
Exclusion/exclusion range
One or more IP addresses within a DHCP scope that are not allocated by the DHCP Server service. Exclusions ensure that the specified IP addresses will not be offered to clients by the DHCP server as part of the general address pool.
DHCP relay agent
Either a host or an IP router that listens for DHCP client messages being broadcast on a subnet and then forwards those DHCP messages directly to a configured DHCP server. The DHCP server sends DHCP response messages directly back to the DHCP relay agent, which then forwards them to the DHCP client. The DHCP administrator uses DHCP relay agents to centralize DHCP servers, avoiding the need for a DHCP server on each subnet. Also referred to as a BOOTP relay agent.
Unauthorized DHCP server
A DHCP server that has not explicitly been authorized. Sometimes referred to as a rogue DHCP server.
In a Windows Server 2003 domain environment, the DHCP Server service on an unauthorized server running Windows Server 2003 fails to initialize. The administrator must explicitly authorize all DHCP servers running Windows Server 2003 that operate in an Active Directory service domain environment. At initialization time, the DHCP Server service in Windows Server 2003 checks for authorization and stops itself if the server detects that it is in a domain environment and the server has not been explicitly authorized.
Automatic Private IP Addressing (APIPA)
A TCP/IP feature in Windows XP and Windows Server 2003 that automatically configures a unique IP address from the range 169.254.0.1 through 169.254.255.254 with a subnet mask of 255.255.0.0 when the TCP/IP protocol is configured for automatic addressing, the Automatic private IP addressalternate configuration setting is selected, and a DHCP server is not available. The APIPA range of IP addresses is reserved by the Internet Assigned Numbers Authority (IANA) for use on a single subnet, and IP addresses within this range are not used on the Internet.
Superscope
A configuration that allows a DHCP server to provide leases from more than one scope to clients on a single physical network segment.
Multicast IP addresses
Multicast IP addresses allow multiple clients to receive data that is sent to a single IP address, enabling point-to-multipoint communication. This type of transmission is often used for streaming media transmissions, such as video conferencing.
Multicast Scope
A range of multicast IP addresses that can be assigned to DHCP clients. A multicast scope allows dynamic allocation of multicast IP addresses for use on the network by using the MADCAP protocol, as defined in RFC 2730.
BOOTP
An older protocol with similar functionality; DHCP is based on BOOTP. BOOTP is an established protocol standard used for configuring IP hosts. BOOTP was originally designed to enable boot configuration for diskless workstations. Most DHCP servers, including those running Windows Server 2003, can be configured to respond to both BOOTP requests and DHCP requests.