I have a string like so:
hey how are you
I want to change it so its like this:
hey *how are you
with the asterisk after the 1st space. I would like to know the best way to do this. Thanks in advance.
Printable View
I have a string like so:
hey how are you
I want to change it so its like this:
hey *how are you
with the asterisk after the 1st space. I would like to know the best way to do this. Thanks in advance.
Did it myself thanks.
place 2 textboxes and a command button on a formVB Code:
Private Sub Command1_Click() Dim intPos As Integer Dim str As String Dim strStore As String str = Text1.Text intPos = InStr(1, str, " ", vbTextCompare) If intPos > 0 Then ' store string after space strStore = Right$(str, Len(str) - intPos) ' place asterisk after first space Mid$(str, intPos + 1) = "*" End If Text2.Text = Left$(str, intPos + 1) & strStore End Sub Private Sub Form_Load() Text1.Text = "Enter a string" Text2.Text = "" End Sub