Search Tools Links Login

Make Initials Capitals

Posted: 2019-08-22
By: RajuV
Viewed: 146

Filed Under:

VB6 String Handling, VB6 Code Cache

No attachments for this post


Makes the initials characters capital. ie. character after space/hyphen/dot

Public Function MakeInitialsCapital(str As String) As String

   Dim i As Integer, L As Integer
   Dim Prev_char As String * 1
   Dim c As String * 1
   Dim S As String

   Prev_char = " "
   L = Len(str)
   i = 1
   S = ""
   Do While i <= L
      c = Mid(str, i, 1)
      If Prev_char = " " Or Prev_char = "-" Or Prev_char = "." Then
         c = UCase(c)
      Else
         c = LCase(c)
      End If
      If c = "M" Then
         If Mid(str, i + 1, 1) = "g" Or Mid(str, i + 1, 1) = "l" Then
            c = "m"
         End If
      End If
      S = S + c
      Prev_char = c
      i = i + 1
   Loop
   str = S
   MakeInitialsCapital = S
End Function

Special Instructions

This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.