Splitting words in a text box

  reddwarfcrew 20:46 31 Jan 06


I have a VBA macro in Word XP that has 3 textboxs

TextBox1 will contain a name, both first and last name

What I want to do is be able to split the value in TextBox1 into 2 so that TextBox2 contains the first name (ie the text up to the space in TextBox1) and TextBox3 contains the lastname (ie the text in TextBox1 after the space).

Any clues on how to achieve this? I assume I will need to use some form of length function and a function to find the space?


  reddwarfcrew 21:18 31 Jan 06

but sorted anyway with (if anyone is interested)

Dim SearchString, SearchChar, MyPos, First, Last

SearchString = TextBox1.Value
SearchChar = " "

MyPos = InStr(1, SearchString, SearchChar, 1)
MyPos = MyPos - 1

First = Mid(SearchString, 1, MyPos)

MyPos = MyPos + 2

Last = Mid(SearchString, MyPos)

TextBox2.Value = First
TextBox3.Value = Last

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

Method Studios' title sequence for BBC series Taboo is truly unsettling

Best Pages for iOS tips | How to use Pages for iPad & iPhone: 6 simple tips to get more out of…