• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Using Procedures to Customiz... > Using Functions to Customize Your Ap...

Using Functions to Customize Your Applications

Now let’s look at a function that performs exactly the same operation, but does so with much less code. This function is provided for you in the Convention database from your download. You don’t have to add or remove spaces with this function because it simply checks and changes each character as it goes. Let’s see how it works.

Function CapFirstLetter(StrInput As String) 
Dim Mark As Integer, Char As String 

For i = 1 To Len(StrInput) 
  Char = Mid(StrInput, i, 1) 
  If Char = " " Then 
    Mark = i 
  ElseIf i = Mark + 1 Then 
    Mid(StrInput, i, 1) = UCase(Mid(StrInput, i, 1)) 
  Else 
    Mid(StrInput, i, 1) = LCase(Mid(StrInput, i, 1)) 
  End If 
Next i 
CapFirstLetter = StrInput 

End Function 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint