Results 1 to 21 of 21

Thread: [RESOLVED] Repeating first 2 characters?

Threaded View

  1. #10
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Repeating first 2 characters?

    My earlier suggestion as a function:
    Code:
    Option Explicit
    
    Public Function Alternate(Expression As String, Optional ByVal Length As Long = 2) As String
        Select Case Length
        Case Is < 1
        Case 1
            If Len(Expression) Then Alternate = String$(Len(Expression), Left$(Expression, 1))
        Case Else
            Alternate = Expression
            If Length < Len(Expression) Then Mid$(Alternate, 1 + Length) = Alternate
        End Select
    End Function
    
    Private Sub Form_Load()
        Debug.Print Alternate("1234567890", 3)
    End Sub
    Last edited by Merri; Jul 21st, 2010 at 10:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width