Splitting words in a text box

  reddwarfcrew 20:46 31 Jan 06
Locked

Hi,

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?

Thanks

  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.

Surface Pro 5 News - release date, UK price, features, specs

Animator Emanuele Kabu’s psychedelic video is a stunning tribute to Lisbon city

Best Mac antivirus 2017