i just have myvar="61-DE RUBERTIS GIOVANNI-(14/05/1989)-(INS)"
How to get the value from the last ( and )?
In my case INS, and assign the current value to myvar1
Note:
The internal of ( and ) are only 2 value MOD and INS
Naturally the lenght of myvar is variable
get value between ( and )
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 2StarLounger
- Posts: 176
- Joined: 11 Jun 2012, 20:37
Re: get value between ( and )
Do you have InStrRev in vb?
In case the last set of parentheses is not exactly at the end of the string:
myvar = "61-DE RUBERTIS GIOVANNI-(14/05/1989)-(INS)"
x = InStrRev(myvar, "(") + 1
y = InStrRev(myvar, ")")
myvar1 = Mid(myvar, x, y - x)
or shorter:
myvar = "61-DE RUBERTIS GIOVANNI-(14/05/1989)-(INS)"
x = InStrRev(myvar, "(") + 1
myvar1 = Mid(myvar, x, InStrRev(myvar, ")") - x)
In case the last set of parentheses is not exactly at the end of the string:
myvar = "61-DE RUBERTIS GIOVANNI-(14/05/1989)-(INS)"
x = InStrRev(myvar, "(") + 1
y = InStrRev(myvar, ")")
myvar1 = Mid(myvar, x, y - x)
or shorter:
myvar = "61-DE RUBERTIS GIOVANNI-(14/05/1989)-(INS)"
x = InStrRev(myvar, "(") + 1
myvar1 = Mid(myvar, x, InStrRev(myvar, ")") - x)
-
- 5StarLounger
- Posts: 742
- Joined: 27 Jun 2021, 10:46
Re: get value between ( and )
Or
Mid(myvar, Len(myvar) - 3, 3)
There is more than one way to skin a cat ... :-)
Mid(myvar, Len(myvar) - 3, 3)
There is more than one way to skin a cat ... :-)