2017-07-28 20:46 GMT-03:00 PICCORO McKAY Lenz <mckaygerh...@gmail.com>:

> 2017-07-28 17:17 GMT-04:00 Fernando Cabral <fernandojosecab...@gmail.com>:
>
>> > in the following code:
>> >     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>> > What does inStr() returns if nothing is found? You may be passing an
>> invalid argument to Mid().
>> Please, check it up.
>>
>
> fernando check it up you, if i do the instr() -1 separately works... dou
> you see the code before answer:
>
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1) ' does
> not work
>
> IDE said error invalid argument, but if i do:
>
>     psotionlen = InStr(strinchar, ")", -1) - 1   ' separate the stolen
> and..
>      strinchar = Mid(strinchar, 1, psotionlen)  ' put in here then works
> ?!?!?!!?
>
> works, why?
>

I did the following test. It did not work as expected, but it did work.
I mean, I got no errors, but it did not work as expected in the sense that
the search seems always to be done from left to right, not right to left,
even if the third parameter is negative.

   Dim strinchar As String
   Dim positionlen As Integer

    strinchar = "test )after)r"
    positionlen = String.InStr(strinchar, ")", -1) - 1
    Print strinchar
    Print positionlen
    strinchar = Mid(strinchar, 1, positionlen)
    Print strinchar
    strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
    Print strinchar


This prints:

test )after)r
5
test
test

Regards

- fernando



>
>> - fernando
>>
>> > IDE said error invalid argument, but if i do:
>> >
>> >     psotionlen = InStr(strinchar, ")", -1) - 1
>> >      strinchar = Mid(strinchar, 1, psotionlen)
>> >
>> > works, why?
>> >
>> > i wnat to remove the last occurence of a char but bybass some possible
>> > spaces/chars at the end of string
>> >
>> > Lenz McKAY Gerardo (PICCORO)
>> > http://qgqlochekone.blogspot.com
>> > ------------------------------------------------------------
>> > ------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > _______________________________________________
>> > Gambas-user mailing list
>> > Gambas-user@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >
>>
>>
>>
>> --
>> Fernando Cabral
>> Blogue: http://fernandocabral.org
>> Twitter: http://twitter.com/fjcabral
>> e-mail <http://twitter.com/fjcabral%0Ae-mail>:
>> fernandojosecab...@gmail.com
>> Facebook: f...@fcabral.com.br
>> Telegram: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>> Wickr ID: fernandocabral
>> WhatsApp: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>> Skype:  fernandojosecabral
>> Telefone fixo: +55 (37) 3521-2183 <%2837%29%203521-2183>
>> Telefone celular: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>>
>> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
>> nenhum político ou cientista poderá se gabar de nada.
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>


-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecab...@gmail.com
Facebook: f...@fcabral.com.br
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to