In the good old times I made code like this:
dim s as Integer = len("test")
I know that I should do constants and what not. But sometimes I don’t want to. How do I do this in API2? A
doesn’t work. Do I have to use a constant or property in API2?
- the old style which still works
- stuff it in a variable first then use Length on that variable
in modul global method but i would still use Len in your case
[code]Public Function Length(s As String) as Integer
Var Test as String = "TEST"
Var s As Integer = Test.Lenght
Thanks, guys. The Feedback case from Norman is the one I want.
dim s as Integer = Ctype(“test”, String).Length also works for literals or constants.
Using CType is possible but verbose and slow. We should really be able to either use a global Len/Length function or a “xxx”.length form with the compiler optimising the code.