Reputation: 2019
I've this string:
TEST|TEST1|TEST3|TEST4|TEST5|TEST6|TEST7|TEST8|
I need to select TEST8
using VBS. Is there a better way then using MID/INSTR
? For example, selecting directly only the characters UNTIL |
from right to left?
PS.: I only have these functions available:
Ascii
Char
Compare
DigText
Format
InStr
LCase
Len
Left
LTrim
Mid
Right
RTrim
Trim
UCase
Upvotes: 2
Views: 5038
Reputation: 38765
Use Split(), if your data is a string with parts separated by a simple separator; use UBound() to get at the last element in a flexible way:
>> s = "TEST|TEST1|TEST3|TEST4|TEST5|TEST6|TEST7|TEST8"
>> a = Split(s, "|")
>> WScript.Echo a(Ubound(a))
>>
TEST8
Upvotes: 5