| re: VBScript - Get text inside string & remove text from string
dear,
You have to look for the places of the "[" and the "]".
like=
form with:
textbox = Text1
1e label = Label1
2e label = Label2
command = Command1
use the code=
=================================================
Private Sub Command1_Click()
With Text1
Label1.Caption = Mid(.Text, InStr(.Text, "[") + 1, InStr(.Text, "]") - 1 - InStr(.Text, "["))
Label2.Caption = Left(.Text, InStr(.Text, "[") - 1)
End With
End Sub
=================================================
- 1e looking for the value in the "[" and the "]"=
You needs the string in the middle of a string so:
Mid(string,...)
The value starts at the place of the "[" +1 so:
InStr(.Text, "[") + 1
The lenght of the value is= place of "]"-1 min the place of the "[" so:
InStr(.Text, "]") - 1 - InStr(.Text, "[")
- 2e text before the value=
The left of the string until the place of the "[" -1 so:
Left(.Text, InStr(.Text, "[") - 1)
I hope this will help you.
br,
|