At 3:11 PM -0700 9/30/06, Phil M wrote:
The second surprise was that Extends works with array types.

FWIW Extends also works with base types like Integer and String.

Instead of using the ever maligned STR function I coded my own version

Function AsText(Extends i as integer, fmt as string = "-0") As string
  return Format(i, fmt)
End Function


and most of the time I just call it like this;

  MsgBox "This is an integer displayed as text: " + MyInteger.AsText

Regards,
Joe Huber

Hi Joe,

Thanks for the code. I like it and I use it but bec careful with this.
I recommend that you change it to:

Function AsText(Extends i as integer, fmt as string = "-0") As string
 return DefineEncoding(Format(i, fmt), Encodings.UTF8)
End Function


The top version returns a NIL encoded string and if you later concatenate this with another string, the resulting string will also have a NIL encoding and then you can get bitten by some subtle (ie catastrophic) differences with InStr(), countStr etc.

The bottom one fixes this nasty little creepy crawly ....

(Can you tell I just got bitten by it...)
--

Cheers,

Dr Gerard Hammond
MacSOS Solutions
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to