Register Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • XxLithiumxX
    New Member
    • Oct 2006
    • 5

    #1

    Register Program

    I am Currently making a program so i can enter a name
    eg
    Joe Bloggs
    and switch the names around
    eg
    Bloggs Jow

    Any ideas how to do this i am stuck
    I have started of by inputing the name then finding the space.
    were do i go from hear or i am i completly on the wrong track

    Private Sub cmdSwitch_Click ()

    namein = txtNameIn

    spacepos = InStr(namein, " ")



    End Sub
  • LifeEquals42
    New Member
    • Jul 2006
    • 7

    #2
    Take a look at the Split Function

    Comment

    • willakawill
      Top Contributor
      • Oct 2006
      • 1646

      #3
      Originally posted by XxLithiumxX
      I am Currently making a program so i can enter a name
      eg
      Joe Bloggs
      and switch the names around
      eg
      Bloggs Jow

      Any ideas how to do this i am stuck
      I have started of by inputing the name then finding the space.
      were do i go from hear or i am i completly on the wrong track

      Private Sub cmdSwitch_Click ()

      namein = txtNameIn

      spacepos = InStr(namein, " ")



      End Sub
      This will work and will help you to understand string functions:

      Dim stTitle As String
      Dim stFirst As String
      Dim stLast As String

      'assign the original string
      stTitle = "John Smith"

      'assign the left part of the string up to the last character before the space
      stFirst = Left(stTitle, InStr(stTitle, " ") - 1)

      'assign the right part of the string after the space
      stLast = Right(stTitle, Len(stTitle) - InStr(stTitle, " "))

      'swap the strings around
      stTitle = stLast & " " & stFirst

      'see what it looks like
      MsgBox stTitle

      Comment

      Working...