January 2012
M T W T F S S
« Jan    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [+]C++ (13) 
  • [+]Delphi (20) 
  • [+]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [+]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 4 Guests
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • Demonstration of using System.Environment type

    This example demonstrates the usage of System.Environment type:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Program
    {
        class Program
        {
            static int Main(string[] args)
            {
    
                ShowEnvironmentDetails();
                Console.ReadLine();
                return -1;
            }
            static void ShowEnvironmentDetails()
            {
                // Print out the drives on this pc,
                // OS version and other details.
                foreach (string drive in Environment.GetLogicalDrives())
                Console.WriteLine("Drive: {0}", drive);
                Console.WriteLine("OS: {0}", Environment.OSVersion);
                Console.WriteLine("Number of processors: {0}",Environment.ProcessorCount);
                Console.WriteLine(".NET Version: {0}",Environment.Version);
                Console.WriteLine("User name: {0}", Environment.UserName);
                Console.WriteLine("Domain name: {0}", Environment.UserDomainName);
                Console.WriteLine("Machine name: {0}", Environment.MachineName);
                Console.WriteLine("Current directory: {0}", Environment.CurrentDirectory);
            }
        }
    }
    

    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Print command-line arguments

    This example demonstrates how to print arguments that are passed to a program through a command line:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Program
    {
        class Program
        {
            static int Main(string[] args)
            {
    
                // Process any incoming args using 'for' keyword.
                for (int i = 0; i < args.Length; i++)
                    Console.WriteLine("Arg: {0}", args[i]);
    
                Console.ReadLine();
                return -1;
            }
        }
    }
    

    Compile and run this program from the command line adding any arguments after exe file. For example running: ArgsTest.exe -arg1 -arg2 -arg2 will produce the following result:


    The same as above but using ‘foreach’ keyword:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Program
    {
        class Program
        {
            static int Main(string[] args)
            {
    
                // Get arguments using System.Environment.
                string[] theArgs = Environment.GetCommandLineArgs();
                foreach (string arg in theArgs)
                    Console.WriteLine("Arg: {0}", arg);
    
                Console.ReadLine();
                return -1;
            }
        }
    }
    


    Another method using GetCommandLineArgs() method of the System.Environment type.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Program
    {
        class Program
        {
            static int Main(string[] args)
            {
    
                // Get arguments using System.Environment.
                string[] theArgs = Environment.GetCommandLineArgs();
                foreach (string arg in theArgs)
                    Console.WriteLine("Arg: {0}", arg);
    
                Console.ReadLine();
                return -1;
            }
        }
    }
    

    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    T-SQL: Find logical name and physical location of system databases

    The following T-SQL statements will print the logical name and physical location of system database files:

    USE master;
    GO
    SELECT name, physical_name AS CurrentLocation, state_desc
    FROM sys.master_files
    WHERE database_id = DB_ID(N'master')
    
    SELECT name, physical_name AS CurrentLocation, state_desc
    FROM sys.master_files
    WHERE database_id = DB_ID(N'tempdb')
    
    SELECT name, physical_name AS CurrentLocation, state_desc
    FROM sys.master_files
    WHERE database_id = DB_ID(N'model')
    
    SELECT name, physical_name AS CurrentLocation, state_desc
    FROM sys.master_files
    WHERE database_id = DB_ID(N'msdb')
    

    Result:

    image

    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    What's new in SQL Server 2008

    SQL SERVER 2008 DATABASE IMPLEMENTATION AND MAINTENANCE
    MCTS EXAM: 70-432
    ===================================================================
    Exam Objectives:
    	1)  New Features in SQL Server 2008
    	2)  Installing SQL Server 2008
    	3)  Configuring SQL Server 2008
    	4)  Managing Security
    	5)  Managing Data Encryption
    	6)  Managing High Availability
    	7)  Maintaining Your Database
    	8 )  ETL Techniques
    	9)  Managing Replication
    	10) Monitoring and Troubleshooting
    	11) SQL Server XML Support
    	12) Service Broker
    	13) Performance Tuning
    	14) Implementing Objects
    ====================================================================
     Continue reading New Features in SQL Server 2008
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Matching IP Address using the Regular Expression

    Author: Zaur Bahramov Description: This example demonstrate the quick and simple way to match correct IP address.

    MatchesDemo.zip

    ipOK

    ipBad

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    
    namespace MatchesDemo
    {
        public partial class IPValidate : Form
        {
            public IPValidate()
            {
                InitializeComponent();
            }
    
            private void btnValidate_Click(object sender, EventArgs e)
            {
                // MessageBox.Show(mtxtIPAddress.Text);
    
                // create a regex object
                Regex checkIP = new Regex (@"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b");
    
                // create match
                Match matchIP = checkIP.Match(mtxtIPAddress.Text);
    
                if (checkIP.IsMatch(mtxtIPAddress.Text))
                {
                    mtxtIPAddress.ForeColor = Color.Green;
                }
                else
                    mtxtIPAddress.ForeColor = Color.Red;
            }
        }
    }
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Demonstration of IsMatch() method

    Author: Zaur Bahramov

    Description: This example demonstrates the usage of IsMatch() method in C#.NET

     using System;
    using System.Text.RegularExpressions;
    
    namespace IsMatchDemo
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine(@"This will find a match for the regular expression'[A-Z]\d\d'.");
                Console.WriteLine("Enter a test string now.");
    
                // create regex to match any alphabetical character, followed by a digit
                Regex myRegex = new Regex(@"[A-Z]\d\d", RegexOptions.IgnoreCase);
    
                // create a string variable to store input from user
                string inputString;
    
                // read input
                inputString = Console.ReadLine();
    
                // create object variable Match as inheriting from Match class
                Match myMatch = myRegex.Match(inputString);
    
                string outputString = "The following option(s) are set: ";
    
                // print selected regex option
                Console.WriteLine(outputString + myRegex.Options.ToString());
    
                // print string typed by user
                Console.WriteLine("You entered the string: '" + inputString + "'.");
    
                // check wether the match occured
                if (myRegex.IsMatch(inputString))
                    Console.WriteLine("The match '" + myMatch.ToString() + "' was found in the string you entered.");
                else
                Console.WriteLine("No match was found.");
    
                Console.ReadLine();
            }
        }
    }
     

    Output:

    This will find a match for the regular expression’[A-Z]\d\d’.
    Enter a test string now.
     -”This is a test text: z75. Is this a match?”
    The following option(s) are set: IgnoreCase
    You entered the string: ‘This is a test text: z75. Is this a match?’.
    The match ‘z75′ was found in the string you entered.
    

    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    POSIX Regex Flavor

    POSIX
    =======================================================
    [:upper:]		Upper case letters
    [:lower:]		Lower case letters
    [:alpha:]		All letters
    [:alnum:]		Digits and letters
    [:digit:]		Digits
    [:xdigit:]		Hexadecimal digits
    [:punct:]		Punctuation
    [:blank:]		Space and tab
    [:space:]		Blank characters
    [:cntrl:]		Control characters
    [:graph:]		Printed characters and spaces
    [:word:]		Digits, letters and underscore
    --------------------------------------------------------
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Enumerate Attributes of an XML Node

    Author: Microsoft 

    ' ----------------------------------------
    '  Required Imports :
    '
    '  System.Xml
    ' ----------------------------------------
    
    For Each attribute As XmlAttribute In node.Attributes
    
    Next
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Add an Element to a XML Document

    Author: Microsoft
    Adds a new element to an XML document instance.

    ' ----------------------------------------
    '  Required Imports :
    '
    '  System.Xml
    ' ----------------------------------------
    
    Dim newElement As XmlNode
    newElement = xmlDoc.CreateElement("Keyword")
    newElement.InnerText = "Value"
    xmlDoc.AppendChild(newElement)
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Using Regular Expressions in Microsoft Word

    In Microsoft Office Word you have to use Wild card to search with regular expressions.
    These are not exactly the same as in other regex flavours.
    To use regular expressions (wildcards) in Word 2003, simply select the  Edit menu;
    then select Find. Alternatively, you can use the equivalent keyboard shortcut Ctrl+F.
    The Find and Replace dialog box opens. Check the use WildCards check box.
    
    Metacharacter		Description
    =============		========================================================
    ?			Nonstandard usage (in Word, it is not a quantifier).
    			Matches a single character. Broadly equivalent to
    			the dot metacharacter (.) in standard syntax.
    
    *			Nonstandard usage. Matches zero or more characters.
    			Broadly equivalent to .* in standard syntax.
    
    < 			Matches the position between a nonalphabetic character
    			and a following alphabetic character. Effectively, a
    			beginning-of-word position metacharacter.
    
    > 			Matches the position between an alphabetic character
    			and a following nonalphabetic character. Effectively,
    			an end-of-word position metacharacter.
    
    [...] 			Character class delimiters.
    
    ! 			Used in character classes as the character class negation
    			metacharacter.
    
    {n,m} 			Quantifier syntax.
    
    @ 			Quantifier. Nonstandard syntax, to match one or more
    			occurrences of the preceding character or group. Equivalent
    			to the + metacharacter in standard syntax.
    
    			EXAMPLES
    ============================================================================================
    Problem: 		Match dates in various country formats
    Sample Text:		2005-12-25
    			12/11/2003
    			01.25.2006
    			03-18-2007
    			07-19-2004
    			2006/09/18
    RegEx 1:		([0-9]{2})[./-]([0-9]{2})[./-]([0-9]{4})
    Replacement 1:		\3-\1-\2
    Explanation:		If all has gone well, the pattern should match the dates that are
    			in U.S. format but not those that are already in international date
    			format. We have assumed that all entries are valid dates. The
    			pattern shown would also match nonsense character sequences such as
    			44/12/5432.
    --------------------------------------------------------------------------------------------
    
    NOTE: Period character in Microsoft Word must be enclosed in square bracket, like this [.]
    Sample: To create a capturing group containing a period, use: ([.])
    
    EXAMPLE:
    Sometimes you can omit a space character between period in the end of sentence and the new sentence.
    In such cases you end up with something like this: "He goes to work.He takes a taxi."
    To match lower-case alphabetic character, followed by period and followed by upper-case character
    the following RegEx can be successfully applied: [a-z][.][A-Z]. If you need to make a replacement
    you should use it within a capturing groups, like this: ([a-z][.])([A-Z])
    Replacement string will be: \1 \2 (note the space between \1 and \2!)
    

     

    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews
    Page 1 of 28123451020...Last »