Ask Your Question
0

VBA function return value is incorrect

asked 2019-10-27 09:50:47 +0100

mbarna960 gravatar image

The following VBA function returns only uppercase letters. Is that normal behavior? LO ver: 6.2.7.1, os: Windows 10 (x64) hu-HU

Function FirstUpper( sString As String ) As string
    FirstUpper = UCase( Left( sString, 1 ) + LCase( Mid( sString, 2 ) )
End Function
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-10-27 10:05:58 +0100

keme gravatar image

updated 2019-10-27 10:07:54 +0100

In your function, UCase takes the result of LCase() too.

Insert a closing parenthesis to UCase before the +

FirstUpper = UCase( Left( sString, 1 ) ) + LCase( Mid( sString, 2 ) )
edit flag offensive delete link more

Comments

Thank you, I couldn't see the forest from the tree...

mbarna960 gravatar imagembarna960 ( 2019-10-27 11:04:27 +0100 )edit

Note that what happened in the original code was tdf#80731, i.e. accepting missing closing parenthesis. Unfortunately, due to wide-spread occurrences of that error, fixing that was reverted... Sad. It would prevent the problem in the first place.

Mike Kaganski gravatar imageMike Kaganski ( 2019-10-27 11:07:03 +0100 )edit
Mike Kaganski gravatar imageMike Kaganski ( 2019-11-10 12:49:13 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-10-27 09:50:47 +0100

Seen: 24 times

Last updated: Oct 27