[Gambas-user] why this could not be? error in runtime?

Christof Thalhofer chrisml at ...3340...
Sun Jul 30 00:08:47 CEST 2017


Am 28.07.2017 um 22:55 schrieb PICCORO McKAY Lenz:

> in the following code:
> 
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
> 
> IDE said error invalid argument, but if i do:

No, the IDE says nothing:

Public Sub Test()

  Dim strinchar As String
  Dim psotionlen As Integer

  ' ------------------------------------------------- 1
  strinchar = "strat)edn1"

  strinchar = Mid(strinchar, 1, InStr(strinchar, "u", -1) - 1)

  Print strinchar

  ' ------------------------------------------------- 2
  strinchar = "strat)edn1"

  psotionlen = InStr(strinchar, ")", -1) - 1
  strinchar = Mid(strinchar, 1, psotionlen)

  Print strinchar

  ' ------------------------------------------------- 3
  ' but the only thing this does is (AFAIK)

  strinchar = "strat)edn1"

  Print Left(strinchar, Len(strinchar) - 1)

End

Result is:

strat)edn
strat)edn
strat)edn

:-)

Maybe you should write and code a little slower. ;-)


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20170730/7cef9b24/attachment.sig>


More information about the User mailing list