Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get first 4 letters of second word (2000 / 2003)

    Hi everyone,

    I have a txtbox call txtName I want to get the first 2 letters of the first word and the first 4 letters of the second word and user the result to set the value of another textbox called txtUser.

    Heres what I have (not working)

    Private Sub txtName_AfterUpdate()
    Dim strUser As String
    Dim strUser1 As String
    Dim strUser2 As String

    strUser = Me.txtName
    strUser1 = Left(strUser, 2)
    strUser2 = Left(Split(strUser, " "), 4)

    Me.txtUSER = strUser1 & strUser2
    End Sub

    I don't know how to idetifiy the second word. Many thanks
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get first 4 letters of second word (2000 / 2003)

    You don't indicate which item of Split(strUser) you want to use. The first item has index 0, the second has index 1 etc. So try

    strUser2 = Left(Split(strUser)(1), 4)

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get first 4 letters of second word (2000 / 2003)

    Thanks Hans, works great
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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