STILL on instr... sorry

User avatar
sal21
PlatinumLounger
Posts: 3970
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: 73832
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: 3970
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!

User avatar
sal21
PlatinumLounger
Posts: 3970
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

sorry, bro... can you arrange the code for:

STRINGA ="Stai visualizzando le righe 1 - 4 su 4 totali"

fixed string are:

Stai visualizzando le righe 1 -
and
su
and
totali

i need to have for...
"Stai visualizzando le righe 1 - 4 su 4 totali"
i need to have NUMPAG = 4 NUMREK = 4
i need to have for...
"Stai visualizzando le righe 1 - 20 su 2142 totali"
i need to have NUMPAG = 20 NUMREK = 2142
i need to have for...
"Stai visualizzando le righe 1 - 11 su 1178 totali"
i need to have NUMPAG = 11 NUMREK = 1178
ecc...

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

Re: STILL on instr... sorry

Post by HansV »

Code: Select all

    Dim STRINGA As String
    Dim NUMPAG As Long
    Dim NUMREK As Long
    Dim a() As String
    '...

    STRINGA = "Stai visualizzando le righe 1 - 4 su 5 totali"
    a = Split(Mid(STRINGA, 33))
    NUMPAG = a(0)
    NUMREK = a(2)
    Debug.Print NUMPAG, NUMREK
Regards,
Hans

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

Re: STILL on instr... sorry

Post by sal21 »

HansV wrote:
04 Feb 2022, 14:53

Code: Select all

    Dim STRINGA As String
    Dim NUMPAG As Long
    Dim NUMREK As Long
    Dim a() As String
    '...

    STRINGA = "Stai visualizzando le righe 1 - 4 su 5 totali"
    a = Split(Mid(STRINGA, 33))
    NUMPAG = a(0)
    NUMREK = a(2)
    Debug.Print NUMPAG, NUMREK
:clapping: