STILL on instr... sorry

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

STILL on instr... sorry

Post by sal21 »

i have in STRINGA var:

STRINGA ="Pagina 1 di 31 (607 elementi)"

"Pagina 1" have same position. Same lenght
"elementi" is always present in stringa.

i need to get, and assign to var NUMPAG="31", and in a var NUMREK="607", in this case.

the lenght of 31 and 607, are variable, and i can have for example:

Pagina 1 di 131 (67 elementi)
Pagina 1 di 3 (1457 elementi)
Pagina 1 di 45879 (45 elementi)

the var NUMPAG and NUMREK are Integer

i dont remember but Hans, post a solution with p1 and p2 and instr... but not found

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

Re: STILL on instr... sorry

Post by HansV »

Like this:

Code: Select all

    Dim STRINGA As String
    Dim NUMPAG As Long
    Dim NUMREK As Long
    Dim a() As String
    Dim b() As String

    ...

    STRINGA = "Pagina 1 di 31 (607 elementi)"
    a = Split(STRINGA, " (")
    b = Split(a(0))
    NUMPAG = b(UBound(b))
    b = Split(a(1))
    NUMREK = b(0)
    Debug.Print NUMPAG, NUMREK
Regards,
Hans

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

Re: STILL on instr... sorry

Post by sal21 »

HansV wrote:
14 Jan 2022, 20:21
Like this:

Code: Select all

    Dim STRINGA As String
    Dim NUMPAG As Long
    Dim NUMREK As Long
    Dim a() As String
    Dim b() As String

    ...

    STRINGA = "Pagina 1 di 31 (607 elementi)"
    a = Split(STRINGA, " (")
    b = Split(a(0))
    NUMPAG = b(UBound(b))
    b = Split(a(1))
    NUMREK = b(0)
    Debug.Print NUMPAG, NUMREK
TKS BRO.
great!