Gustav Brock
Gustav at cactus.dk
Mon Sep 26 01:11:13 CDT 2011
Hi Stuart Well, thanks! That's the first time ever I heard and got demonstrated a decent explanation on this$. /gustav >>> stuart at lexacorp.com.pg 26-09-2011 03:41 >>> Format returns a Variant of type String. Format$ returns an actual string. Similarly with Left,Right,Mid,Trim etc Theoretically, using the native types rather than variants should be more efficient. Wait a minute.... Yep - that's true in practice as well: <code> Option Compare Database Option Explicit Const gc_testcases As Long = 10000000 Function TestVar() As String Dim str As String Dim strResult As String Dim t As Single Dim x As Long t = Timer For x = 1 To gc_testcases str = Left("abcdef", 3) Next t = Timer - t strResult = "Variant form took " & t & " seconds" & vbCrLf t = Timer For x = 1 To gc_testcases str = Left$("abcdef", 3) Next t = Timer - t TestVar = strResult & "String form took " & t & " seconds" End Function </code> The Variant form consistently takes 2.5 times as long as the String version. -- Stuart On 26 Sep 2011 at 10:54, Darryl Collins wrote: > Yeah, that was my understanding of it. The "$" is short hand for > String. > > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav > Brock Sent: Friday, 23 September 2011 10:59 PM To: > accessd at databaseadvisors.com Subject: Re: [AccessD] Filtering with > International Dates > > Hi Rocky > > Yes, that will work. It will return #09/23/2011# for today. > > I've never noticed any difference between Format and Format$ (and all > the other old BASIC string handling functions with or without a > trailing $). SomeFunction$ is claimed to always return a string, but > I've never found, say, Trim to return anything else than a string. > Maybe it is just to be compatible with old QBasic or similar. > > /gustav