Sign in to follow this  
Followers 0
edy

Change StringMid ()

6 posts in this topic

Is it possible with stringmid () extract string to left of start positon:

example:

$var = StringMid("string", 3, -2)

MsgBox(0, "2 chars extracted from position 3 are:", $var)

$var = "tr"

Share this post


Link to post
Share on other sites



If you want $var = "tr"

$var = StringMid("string", 2, 2)
MsgBox(0, "2 chars extracted from position 3 are:", $var)

Does this help?

Share this post


Link to post
Share on other sites

If you want $var = "tr"

$var = StringMid("string", 2, 2)
MsgBox(0, "2 chars extracted from position 3 are:", $var)

Does this help?

<{POST_SNAPBACK}>

"string" is for example a substring of another string and i don't know the start position but i find it with the function StringInStr ().

example:

$stringa = " uno due tre 11/3/04 quattro cinque"

$pos = StringInStr ( $stringa, "/" )

$var = StringMid("string", $pos-1, -2)

With the change of stringMid () $var must be "11"

Share this post


Link to post
Share on other sites

"string" is  for example a substring of another string  and i don't  know the start position but i  find it with the function StringInStr ().

example:

$stringa = " uno due tre  11/3/04 quattro cinque"

$pos = StringInStr ( $stringa, "/"  )

$var = StringMid($stringa, $pos-1, -2)

With the change of stringMid ()  $var  must  be  "11"

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It would be a nice addition.

But you can do it by hand. I'll take your example:

$stringa = " uno due tre  11/3/04 quattro cinque"

$endpos = StringInStr ( $stringa, "/"  )
$startpos = $endpos - 2
$var = StringMid($stringa, $startpos, $endpos - $startpos)
MsgBox(0, "Test", "$var: " & $var)
Edited by SlimShady

Share this post


Link to post
Share on other sites

Fine, thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0