Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2009, 01:46 AM
Registered User
 
Join Date: Aug 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Some explanation about left function

can anybody explain me.this code.Kindly let me know any idea.any help would be highly appreciated.
Code:
Function GetTens(TensText) 

          Dim Result As String 



          Result = "" ' Null out the temporary function value. 

          If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19... 

              Select Case Val(TensText) 

                  Case 10: Result = " and Ten" 

                  Case 11: Result = " and Eleven" 

                  Case 12: Result = " and Twelve" 

                  Case 13: Result = " and Thirteen" 

                  Case 14: Result = " and Fourteen" 

                  Case 15: Result = " and Fifteen" 

                  Case 16: Result = " and Sixteen" 

                  Case 17: Result = " and Seventeen" 

                  Case 18: Result = " and Eighteen" 

                  Case 19: Result = " and Nineteen" 

                  Case Else 

              End Select
 
Old August 9th, 2009, 02:21 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

The Val function takes a string and returns a numeric value (double).

Left returns x number of characters from a string (Left(String, Length))

So If Val(Left(TensText, 1)) = 1 Then tests to see if the first character is a one (1) and if so then there is the select case statement...

Select Case Val(TensText)
Case 10: Result = " and Ten"

Which this is part of a number to words algorithm and is more than likely to be a number to currency words algorithm where the user would enter say 1.10 and would recieve back one dollar and ten cents.


Good Look





Similar Threads
Thread Thread Starter Forum Replies Last Post
LEFT vs LEFT OUTER joxa83 SQL Server 2005 3 September 18th, 2008 03:13 AM
Undefined function 'Left' in expression Morris Access 13 July 23rd, 2008 02:07 AM
Undefined function 'Left' in expression MountainProud Access 4 October 23rd, 2006 10:48 AM
explanation crmpicco Classic ASP Components 3 February 2nd, 2005 12:14 AM
i need explanation ... amahja56 C++ Programming 2 October 28th, 2004 05:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.