StringIndexOutOfBoundsExeption

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I used:
str1.SubString2(8,10) & "-" & str1.SubString2(5,7) & "-" & str1.SubString2(0,4).

This works fine in the past, but now I got:
StringIndexOutOfBoundsExeption

Nothing changed, just new compile.

Not using SubString works fine.

Can somebody help?

Thanks,
André
 

klaus

Expert
Licensed User
Longtime User
What is the content of str1 ?
What do you do with str1.SubString2(8,10) & "-" & str1.SubString2(5,7) & "-" & str1.SubString2(0,4) ?

Just, be aware of this 'The new string will include the character at BeginIndex and will extend to the character at EndIndex, not including the last character'.
Best regards.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
SOLVED.

str1 should contain a value.

Changed my code to:
If str1 <> "" Then
sel.Second = sel.Second &" / " & str1.SubString2(8,10) & "-" & str1.SubString2(5,7) & "-" & str1.SubString2(0,4)
End If

I used the code to change a date field from YYYYMMDD to DD-MM-YYYY.

Thanks for helping.

Best regards,
André
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…