Visual Basic
  Home arrow Visual Basic arrow Page 5 - Developing an XML Web Service Using Visual...
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

Developing an XML Web Service Using Visual Studio 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 56
    2005-12-13

    Table of Contents:
  • Developing an XML Web Service Using Visual Studio 2005
  • Brief explanation of the “Number to Words” XML Web Service
  • Creating XML Web Service using Visual Studio 2005
  • Developing the XML Web Service
  • Developing the XML Web Service continued
  • Executing and testing the XML Web Service

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Developing an XML Web Service Using Visual Studio 2005 - Developing the XML Web Service continued


    (Page 5 of 6 )

    Now, let us proceed with the “Process3DigitNumber” method, which is usually called “ConvertToWords”.

    private string Process3DigitNumber(string sSource)
        {
            string sRetVal = "";
            //Make sure the source should be three digits
            sSource = "000" + sSource;
            sSource = sSource.Substring(sSource.Length - 3);
     
            //Hundred possion
            if (sSource.Substring(0, 1) != "0")
                sRetVal = ProcessSingleDigitNumber(sSource.Substring(0, 1)) + " Hundred ";
     
            //Tens and ones possion
            if (sSource.Substring(1, 1) != "0")
                sRetVal += Process2DigitNumber(sSource.Substring(1));
            else
                sRetVal += ProcessSingleDigitNumber(sSource.Substring(2));
     
            return sRetVal;
        }

    Once the above method receives a number (as a string), we left pad it with zeroes to make sure that it is a three digit number.  After that, we chunk it further and send it to “Process2DigitNumber” or “ProcessSingleDigitNumber”, which are implemented as follows:

    private string Process2DigitNumber(string sSource)

        {
            string sRetVal = "";
            if (sSource.Substring(0, 1) == "1")
            {
                // Process 10 to 19
                switch (sSource)
                {
                    case "10": sRetVal = "Ten"; break;
                    case "11": sRetVal = "Eleven"; break;
                    case "12": sRetVal = "Twelve"; break;
                    case "13": sRetVal = "Thirteen"; break;
                    case "14": sRetVal = "Fourteen"; break;
                    case "15": sRetVal = "Fifteen"; break;
                    case "16": sRetVal = "Sixteen"; break;
                    case "17": sRetVal = "Seventeen"; break;
                    case "18": sRetVal = "Eighteen"; break;
                    case "19": sRetVal = "Nineteen"; break;
                }
            }
            else
            {
                // Process 20 to 99
                switch (sSource.Substring(0, 1))
                {
                    case "2": sRetVal = "Twenty "; break;
                    case "3": sRetVal = "Thirty "; break;
                    case "4": sRetVal = "Forty "; break;
                    case "5": sRetVal = "Fifty "; break;
                    case "6": sRetVal = "Sixty "; break;
                    case "7": sRetVal = "Seventy "; break;
                    case "8": sRetVal = "Eighty "; break;
                    case "9": sRetVal = "Ninety "; break;
                }
                //Append single digit word
                sRetVal += ProcessSingleDigitNumber(sSource.Substring(1));
            }
            return sRetVal;
        }

    I hope I don't need to explain much about the above method.  It simply returns the string based on the two digit value sent to it.  This method may further call “ProcessSingleDigitNumber” to process only single digits.  Let us see how that is implemented.

    private string ProcessSingleDigitNumber(string sSource)
        {
            string sRetVal = "";
            switch (sSource)
            {
                case "1": sRetVal = "One"; break;
                case "2": sRetVal = "Two"; break;
                case "3": sRetVal = "Three"; break;
                case "4": sRetVal = "Four"; break;
                case "5": sRetVal = "Five"; break;
                case "6": sRetVal = "Six"; break;
                case "7": sRetVal = "Seven"; break;
                case "8": sRetVal = "Eight"; break;
                case "9": sRetVal = "Nine"; break;
                default: sRetVal = ""; break;
            }
     
            return sRetVal;
        }

    And thus, our coding (development) part is successfully finished.

    More Visual Basic Articles
    More By Jagadish Chaterjee


       · I hope this article gave you a good grounding in how to develop an XML web service,...
       · I'm confortable with web service development. However, you should have completed how...
       · Very good explaination up to this point but cut a bit short. Perhaps it will be...
       · well i guess the title says it all, i need to know how to use it now... do i need...
       · Here is the VB Code for those who don't feel like translating C#.Imports...
       · File->Add to project->create or add an existing onein that project add web...
       · I have the same problem that the undersigned has. The only differance is that I have...
     

    VISUAL BASIC ARTICLES

    - Developing an XML Web Service Using Visual S...
    - Creating an HTML File List with VB
    - Fun with Email: VB6, CDO, MAPI, and a Remote...
    - Extranet/Intranet Dictionary Cracker in VB
    - Finding Default App Icons With Visual Basic
    - Registry Fever With Visual Basic
    - Implementing An ADO Data Control With VB6
    - Printing With Visual Basic
    - MSMQ Part 1/2: Architecture and Simple Imple...
    - Magnifying The Desktop With Visual Basic
    - Sending Email With MAPI Components in Visual...
    - Two Person Chat With The Winsock Control And...
    - A Real-Time ActiveX News Control
    - Accessing the Windows API in Visual Basic







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway