Prev: crack for VSFlex8 in VB6.0
Next: Component Handles
From: Nobody on 5 Oct 2009 20:12 "Eduardo" <mm(a)mm.com> wrote in message news:hadvdo$dll$1(a)aioe.org... > I remeber I've read something in the past about that: > > Call Function (Parameter1, Parameter2) > > was in some way handled different that > > Function Parameter1, Parameter2 > > But I don't remember what the difference was. > It would be interesting if someone could explain if there is really any > difference and what is it about. There is no difference. I think you are remembering something else. When you want to pass a parameter ByVal when a parameter was declared ByRef, one way is to surround it with () so VB treat it as expression. In this case, VB puts the result of the expression in a temporary location in memory, then passes the pointer to it. The function modifies this temporary location and the result is discarded afterward. Example: ' Form1 Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _ Destination As Any, Source As Any, ByVal Length As Long) Private Sub Form_Load() Dim i As Long i = 1 Debug.Print "GetTestValue: " & GetTestValue(i) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue((i)) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue(i + 0) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue(100) Debug.Print "i after the call = " & i End Sub Private Function GetTestValue(ByRef x As Long) As Long GetTestValue = x * 2 x = 5 End Function Output: GetTestValue: 2 i after the call = 5 GetTestValue: 2 i after the call = 1 GetTestValue: 2 i after the call = 1 GetTestValue: 200 i after the call = 1
From: Eduardo on 5 Oct 2009 20:52 Nobody escribi�: > ' Form1 > > Option Explicit > > Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _ > Destination As Any, Source As Any, ByVal Length As Long) > > Private Sub Form_Load() > Dim i As Long > > i = 1 > Debug.Print "GetTestValue: " & GetTestValue(i) > Debug.Print "i after the call = " & i > i = 1 > Debug.Print "GetTestValue: " & GetTestValue((i)) > Debug.Print "i after the call = " & i > i = 1 > Debug.Print "GetTestValue: " & GetTestValue(i + 0) > Debug.Print "i after the call = " & i > i = 1 > Debug.Print "GetTestValue: " & GetTestValue(100) > Debug.Print "i after the call = " & i > End Sub > > Private Function GetTestValue(ByRef x As Long) As Long > GetTestValue = x * 2 > x = 5 > End Function May be it was that. Thanks. BTW, I modified the code to: Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _ Destination As Any, Source As Any, ByVal Length As Long) Public Declare Function GetPrivateProfileSection Lib "kernel32" _ Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, _ ByVal lpReturnedString As String, ByVal nSize As Long, _ ByVal lpFileName As String) As Long Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _ "GetWindowsDirectoryA" (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long Private Declare Function GetSystemDirectory Lib "kernel32" Alias _ "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal _ nSize As Long) As Long Private Sub Form_Load() Dim i As Long i = 1 Debug.Print "GetTestValue: " & GetTestValue(i) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue((i)) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue(i + 0) Debug.Print "i after the call = " & i i = 1 Debug.Print "GetTestValue: " & GetTestValue(100) Debug.Print "i after the call = " & i End Sub Private Function GetTestValue(ByRef x As Long) As Long GetTestValue = x * 2 x = 5 End Function
From: MikeD on 5 Oct 2009 21:31 You're mistaken. The Call keyword is NEVER required in VB6 either. You just have to make sure you're using the right syntax. -- Mike "Scott M." <s-mar(a)nospam.nospam> wrote in message news:O3azMUgRKHA.4028(a)TK2MSFTNGP05.phx.gbl... > It's supported for legacy reasons, but not needed at all. It's not > included in any code snippets or required as it is in VB 6. In short, > there is no reason to ever use or need it in .NET. > > -Scott > > "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message > news:OpWV$LgRKHA.4592(a)TK2MSFTNGP06.phx.gbl... >> On 2009-10-05, Scott M. <s-mar(a)nospam.nospam> wrote: >>> Not sure what you mean by reading it as "part of the message" and >>> "didn't >>> post it separately", but again, the keyword "Call" is not used in .NET, >>> so >>> it must be a VB 6 question.
From: Scott M. on 6 Oct 2009 16:56 "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message news:%23HOPJlgRKHA.1796(a)TK2MSFTNGP02.phx.gbl... > On 2009-10-05, Scott M. <s-mar(a)nospam.nospam> wrote: >> It's supported for legacy reasons, but not needed at all. It's not >> included >> in any code snippets or required as it is in VB 6. In short, there is no >> reason to ever use or need it in .NET. >> > > Where was it rquired in VB6? > > Besides, required or not is beside the point. It's there, it can be > used - so > you can't judge it to be vb6 code simple because it uses the the call > keyword. > > -- > Tom Shelton I disagree. I think that in "reality" you can very easily make a very accurate educated guess that this code is VB 6 code. -Scott
From: Scott M. on 6 Oct 2009 16:58
"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message news:ed3coqgRKHA.1280(a)TK2MSFTNGP04.phx.gbl... > "Scott M." <s-mar(a)nospam.nospam> wrote in message > news:O3azMUgRKHA.4028(a)TK2MSFTNGP05.phx.gbl... > >> [Call keyword] It's supported for legacy reasons, >> but not needed at all. > > That's not what you said. You said it's "not used", a statement which you > are not qualified to make unless you personally know every single person > in the world who has ever written or will ever write VB.Net code and > unless you have complete details of everything they have ever written and > everything they will ever write :-) > > Mike Well, I disagree with that assesment. You assume my meaning was "it's not used by developes writing code" when the meaning was "it's not used by the development platform". -Scott |