how to get separate value in string between parenthesis

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

how to get separate value in string between parenthesis

Post by sal21 »

... and assign to the fisrt item to LAT end second value to LNG

in my case:

LAT=40.49523
LNG=16.455915

note:
- LAT and LNG are String dimensioned
- the lenght of item between parenthesis are variable
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: how to get separate value in string between parenthesis

Post by HansV »

Code: Select all

    Dim p1 As Long
    Dim p2 As Long
    Dim v As String
    Dim a() As String
    p1 = InStr(STRADE, "(")
    p2 = InStr(p1 + 1, STRADE, ")")
    v = Mid(STRADE, p1 + 1, p2 - p1 - 1)
    a = Split(v, "-")
    LAT = a(0)
    LNG = a(1)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: how to get separate value in string between parenthesis

Post by sal21 »

HansV wrote:
25 Jun 2022, 17:22

Code: Select all

    Dim p1 As Long
    Dim p2 As Long
    Dim v As String
    Dim a() As String
    p1 = InStr(STRADE, "(")
    p2 = InStr(p1 + 1, STRADE, ")")
    v = Mid(STRADE, p1 + 1, p2 - p1 - 1)
    a = Split(v, "-")
    LAT = a(0)
    LNG = a(1)
:clapping: