|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
I must be blind -- what's wrong with this sub?with this module. I created an EXE project with one module, which contains: Option Explicit Public Sub Zzz(p1) Debug.Print "p1 = " & p1 End Sub From the Immediate window: zzz(12) p1 = 12 Good. I change the code as follows: Option Explicit Public Sub Zzz(p1, p2) Debug.Print "p1 = " & p1 End Sub Now from the immediate window: zzz(12,13) Causes: "Compiler error:" "Expected: =" What the heck is wrong? -- For email, use Usenet-20031220@spamex.com "LurfysMa" <invalid@invalid.invalid> wrote in message trynews:4t0kk1lsbd43lergjaa0i131jat5aiq0qb@4ax.com... > Now from the immediate window: > > zzz(12,13) zzz 12,13 Michael or
Call Zzz(12,13) ' the other way to call a Sub To the first Sub call the () means evaluate sort of like ByVal. Then when you have two parameters the () is interpreted as trying to be part of a Function call not a Sub. Show quoteHide quote "Michael C" wrote: > "LurfysMa" <invalid@invalid.invalid> wrote in message > news:4t0kk1lsbd43lergjaa0i131jat5aiq0qb@4ax.com... > > Now from the immediate window: > > > > zzz(12,13) > > try > zzz 12,13 > > Michael > > > On Sun, 9 Oct 2005 23:44:03 -0700, "Lorin"
<Lo***@discussions.microsoft.com> wrote: > Of course. I remember reading about that recently. For a constant>or >Call Zzz(12,13) ' the other way to call a Sub > >To the first Sub call the () means evaluate sort of like ByVal. (literal), it makes no difference, but if it were a variable, the () wold cause it to pass the value rather than the variable even if the parameter was defined as ByRef. Correct? >Then when you have two parameters the () is interpreted as trying to be part So, since "(13)" can be an expression, it is taken that way, but>of a Function call not a Sub. "(12,13)" is not a valid expression, so it is taken as function call syntax. Quirky syntax rules. I would hate to write the parser. Thanks for the help. Show quoteHide quote >"Michael C" wrote: > >> "LurfysMa" <invalid@invalid.invalid> wrote in message >> news:4t0kk1lsbd43lergjaa0i131jat5aiq0qb@4ax.com... >> > Now from the immediate window: >> > >> > zzz(12,13) >> >> try >> zzz 12,13 >> >> Michael >> >> >> -- For email, use Usenet-20031220@spamex.com "LurfysMa" <invalid@invalid.invalid> wrote in message It has nothing to do with constant vs expressionnews:5d4kk1tffrpda4ejqlihte2hteonk2kctr@4ax.com > Of course. I remember reading about that recently. For a constant > (literal), it makes no difference, but if it were a variable, the () > wold cause it to pass the value rather than the variable even if the > parameter was defined as ByRef. Correct? > So, since "(13)" can be an expression, it is taken that way, but Nothing quirky about it at all. VB has two syntaxes used to call a> "(12,13)" is not a valid expression, so it is taken as function call > syntax. Quirky syntax rules. I would hate to write the parser. subroutine (or a function when you are discarding the return value): Call xyz(argumentlist) xyz argumentlist If you omit the CALL keyword then you are using the second syntax and everything after the procedurename is the argument list. In your case you have zzz (12,13) Note that VB inserted a space after 'zzz' which indicates that it is not expecting () around the arguments. It then attempts to resolve '(12,13)' as an expression and fails. You would get the same error if you did Call zzz((12,13),1) since VB would be attempting to evaluate '(12,13)' as the first expression. You can however use either of the following: zzz (10+2),13 Call zzz((12),(10+3)) The 'byval' issue is more of a side effect. If you have a ByRef paremeter and you pass in an expression then on return VB can't update the expression so it discards the changes. That makes it effectively 'ByVal'. For example: zzz a,b ' pass variables (they will be updated if they are defined 'byref') zzz 12,13 ' constants can't be updated so are effectively byval zzz a+1,b+0 ' pass expressions which also can't be updated zzz (a),(b) ' pass simpler expressions Call zzz((a),(b)) ' pass expressions using CALL -- Reply to the group so all can participate VB.Net: "Fool me once..." On Sun, 09 Oct 2005 23:07:09 -0700, LurfysMa <invalid@invalid.invalid>
wrote: Show quoteHide quote >Please help. I am about to break something. I cannot see what's wrong OK, I finally realized one problem, but created another.>with this module. > >I created an EXE project with one module, which contains: > >Option Explicit >Public Sub Zzz(p1) >Debug.Print "p1 = " & p1 >End Sub > >From the Immediate window: > >zzz(12) >p1 = 12 > >Good. > >I change the code as follows: > >Option Explicit >Public Sub Zzz(p1, p2) >Debug.Print "p1 = " & p1 >End Sub > >Now from the immediate window: > >zzz(12,13) > >Causes: > >"Compiler error:" > >"Expected: =" > >What the heck is wrong? The "zzz(12,13)" statement fails because implicit calls to subs do not use parentheses. So, I changed it to: zzz 12,13 This is in the Immediate window. Now I get a new error: Compile error: Expected variable or procedure, not project Huh? But if I put the exact same code into another sub, it works: Option Explicit Public Sub asd() temp 12, 13 End Sub Public Sub temp(p1, p2) Debug.Print "p1 = " & p2 End Sub Public Function zzz(p1, p2) zzz = p1 + p2 End Function Then in the Immediate window: asd p1 = 13 The "temp 12,13" works in one place, but not the other. Now I really need to break something. -- For email, use Usenet-20031220@spamex.com On Sun, 09 Oct 2005 23:53:40 -0700, LurfysMa <invalid@invalid.invalid>
wrote: Show quoteHide quote >On Sun, 09 Oct 2005 23:07:09 -0700, LurfysMa <invalid@invalid.invalid> OK. I think I found the other error. I had been experimenting with>wrote: > >>Please help. I am about to break something. I cannot see what's wrong >>with this module. >> >>I created an EXE project with one module, which contains: >> >>Option Explicit >>Public Sub Zzz(p1) >>Debug.Print "p1 = " & p1 >>End Sub >> >>From the Immediate window: >> >>zzz(12) >>p1 = 12 >> >>Good. >> >>I change the code as follows: >> >>Option Explicit >>Public Sub Zzz(p1, p2) >>Debug.Print "p1 = " & p1 >>End Sub >> >>Now from the immediate window: >> >>zzz(12,13) >> >>Causes: >> >>"Compiler error:" >> >>"Expected: =" >> >>What the heck is wrong? > >OK, I finally realized one problem, but created another. > >The "zzz(12,13)" statement fails because implicit calls to subs do not >use parentheses. So, I changed it to: > > zzz 12,13 > >This is in the Immediate window. Now I get a new error: > > Compile error: > > Expected variable or procedure, not project > >Huh? > >But if I put the exact same code into another sub, it works: > > > >Option Explicit > >Public Sub asd() >temp 12, 13 >End Sub > >Public Sub temp(p1, p2) >Debug.Print "p1 = " & p2 >End Sub > >Public Function zzz(p1, p2) >zzz = p1 + p2 >End Function > > > >Then in the Immediate window: > >asd >p1 = 13 > > >The "temp 12,13" works in one place, but not the other. Now I really >need to break something. DLLs and named one "temp". Dumb. I have deleted the DLL file, but do I need to unregister it? -- For email, use Usenet-20031220@spamex.com "LurfysMa" <invalid@invalid.invalid> wrote in message You should have done that before deleting it.news:rl4kk1paatjq0m70ndd5ur0f5kghoka8qq@4ax.com... > I have deleted the DLL file, but do I need to unregister it? Show quoteHide quote > > -- > For email, use Usenet-20031220@spamex.com On Mon, 10 Oct 2005 17:40:00 +1000, "Michael C"
<mculley@NOSPAMoptushome.com.au> wrote: >"LurfysMa" <invalid@invalid.invalid> wrote in message I see that now. Scanning the registry with regedit, I see that>news:rl4kk1paatjq0m70ndd5ur0f5kghoka8qq@4ax.com... >> I have deleted the DLL file, but do I need to unregister it? > >You should have done that before deleting it. something by that name is still in there. Now I can't run regsrv32 with the "/u" option, right? Is there some safe way for me to unregister that DLL? >> -- >> For email, use Usenet-20031220@spamex.com > -- For email, use Usenet-20031220@spamex.com LurfysMa wrote:
Show quoteHide quote > On Mon, 10 Oct 2005 17:40:00 +1000, "Michael C" If it was deleted to the Recycle Bin, you could always retrieve it, and then> <mculley@NOSPAMoptushome.com.au> wrote: > >> "LurfysMa" <invalid@invalid.invalid> wrote in message >> news:rl4kk1paatjq0m70ndd5ur0f5kghoka8qq@4ax.com... >>> I have deleted the DLL file, but do I need to unregister it? >> >> You should have done that before deleting it. > > I see that now. Scanning the registry with regedit, I see that > something by that name is still in there. > > Now I can't run regsrv32 with the "/u" option, right? > > Is there some safe way for me to unregister that DLL? do the unregistering and deletion... -- Regards, Michael Cole
Show quote
Hide quote
On Mon, 10 Oct 2005 18:56:52 +1000, "Michael Cole" <no***@hansen.com> Good idea. I did that. It said the unregister succeeded. But then, Iwrote: >LurfysMa wrote: >> On Mon, 10 Oct 2005 17:40:00 +1000, "Michael C" >> <mculley@NOSPAMoptushome.com.au> wrote: >> >>> "LurfysMa" <invalid@invalid.invalid> wrote in message >>> news:rl4kk1paatjq0m70ndd5ur0f5kghoka8qq@4ax.com... >>>> I have deleted the DLL file, but do I need to unregister it? >>> >>> You should have done that before deleting it. >> >> I see that now. Scanning the registry with regedit, I see that >> something by that name is still in there. >> >> Now I can't run regsrv32 with the "/u" option, right? >> >> Is there some safe way for me to unregister that DLL? > >If it was deleted to the Recycle Bin, you could always retrieve it, and then >do the unregistering and deletion... repeated the command and it said it succeeded again, and again, etc. It probably says "succeeded" if it's no longer registered even if it never was, but it would be nicer to get a different message. Thanks for the suggestion -- For email, use Usenet-20031220@spamex.com "LurfysMa" <invalid@invalid.invalid> wrote in message That would just add extra unecessary complexity.news:03ckk19ah8d0j3r5rvtqmob1394groevcj@4ax.com... > Good idea. I did that. It said the unregister succeeded. But then, I > repeated the command and it said it succeeded again, and again, etc. > > It probably says "succeeded" if it's no longer registered even if it > never was, but it would be nicer to get a different message. Michael
Show quote
Hide quote
"LurfysMa" <invalid@invalid.invalid> wrote in message I wasn't able to reproduce your error. Likely because I didn't reproducenews:9e3kk1l56somvjmibav556jf5oqpqti1pl@4ax.com... > On Sun, 09 Oct 2005 23:07:09 -0700, LurfysMa <invalid@invalid.invalid> > wrote: > > >Please help. I am about to break something. I cannot see what's wrong > >with this module. > > > >I created an EXE project with one module, which contains: > > > >Option Explicit > >Public Sub Zzz(p1) > >Debug.Print "p1 = " & p1 > >End Sub > > > >From the Immediate window: > > > >zzz(12) > >p1 = 12 > > > >Good. > > > >I change the code as follows: > > > >Option Explicit > >Public Sub Zzz(p1, p2) > >Debug.Print "p1 = " & p1 > >End Sub > > > >Now from the immediate window: > > > >zzz(12,13) > > > >Causes: > > > >"Compiler error:" > > > >"Expected: =" > > > >What the heck is wrong? > > OK, I finally realized one problem, but created another. > > The "zzz(12,13)" statement fails because implicit calls to subs do not > use parentheses. So, I changed it to: > > zzz 12,13 > > This is in the Immediate window. Now I get a new error: > > Compile error: > > Expected variable or procedure, not project > > Huh? > > But if I put the exact same code into another sub, it works: > > > > Option Explicit > > Public Sub asd() > temp 12, 13 > End Sub > > Public Sub temp(p1, p2) > Debug.Print "p1 = " & p2 > End Sub > > Public Function zzz(p1, p2) > zzz = p1 + p2 > End Function > > > > Then in the Immediate window: > > asd > p1 = 13 > > > The "temp 12,13" works in one place, but not the other. Now I really > need to break something. > > -- > For email, use Usenet-20031220@spamex.com your exact steps. Not sure if this is what is happening in your case, but be aware the Intermediate Window can have a long memory. While playing you often need to stop and clear it out. -ralph On Mon, 10 Oct 2005 02:33:50 -0500, "Ralph"
<nt_consultin***@yahoo.com> wrote: Show quoteHide quote > It turned out to be a stray DLL I had been fooling around with. My>"LurfysMa" <invalid@invalid.invalid> wrote in message >news:9e3kk1l56somvjmibav556jf5oqpqti1pl@4ax.com... >> On Sun, 09 Oct 2005 23:07:09 -0700, LurfysMa <invalid@invalid.invalid> >> wrote: >> >> >Please help. I am about to break something. I cannot see what's wrong >> >with this module. >> > >> >I created an EXE project with one module, which contains: >> > >> >Option Explicit >> >Public Sub Zzz(p1) >> >Debug.Print "p1 = " & p1 >> >End Sub >> > >> >From the Immediate window: >> > >> >zzz(12) >> >p1 = 12 >> > >> >Good. >> > >> >I change the code as follows: >> > >> >Option Explicit >> >Public Sub Zzz(p1, p2) >> >Debug.Print "p1 = " & p1 >> >End Sub >> > >> >Now from the immediate window: >> > >> >zzz(12,13) >> > >> >Causes: >> > >> >"Compiler error:" >> > >> >"Expected: =" >> > >> >What the heck is wrong? >> >> OK, I finally realized one problem, but created another. >> >> The "zzz(12,13)" statement fails because implicit calls to subs do not >> use parentheses. So, I changed it to: >> >> zzz 12,13 >> >> This is in the Immediate window. Now I get a new error: >> >> Compile error: >> >> Expected variable or procedure, not project >> >> Huh? >> >> But if I put the exact same code into another sub, it works: >> >> >> >> Option Explicit >> >> Public Sub asd() >> temp 12, 13 >> End Sub >> >> Public Sub temp(p1, p2) >> Debug.Print "p1 = " & p2 >> End Sub >> >> Public Function zzz(p1, p2) >> zzz = p1 + p2 >> End Function >> >> >> >> Then in the Immediate window: >> >> asd >> p1 = 13 >> >> >> The "temp 12,13" works in one place, but not the other. Now I really >> need to break something. >> >> -- >> For email, use Usenet-20031220@spamex.com > >I wasn't able to reproduce your error. Likely because I didn't reproduce >your exact steps. Not sure if this is what is happening in your case, but be >aware the Intermediate Window can have a long memory. mother always told me not to play with those kinds of DLLs, but would I listen? Nooooooooo. >While playing you often need to stop and clear it out. By clear it out, do you mean Ctrl+A then Del?Or something like closing the project? -- For email, use Usenet-20031220@spamex.com
Show quote
Hide quote
"LurfysMa" <invalid@invalid.invalid> wrote in message A select/delete usually does it.news:2c8kk1p7k8mkdadca7f9m2fsv6lu9l6naa@4ax.com... > On Mon, 10 Oct 2005 02:33:50 -0500, "Ralph" > <nt_consultin***@yahoo.com> wrote: > > > > >"LurfysMa" <invalid@invalid.invalid> wrote in message > >news:9e3kk1l56somvjmibav556jf5oqpqti1pl@4ax.com... > >> On Sun, 09 Oct 2005 23:07:09 -0700, LurfysMa <invalid@invalid.invalid> > >> wrote: > >> > >> >Please help. I am about to break something. I cannot see what's wrong > >> >with this module. > >> > > >> >I created an EXE project with one module, which contains: > >> > > >> >Option Explicit > >> >Public Sub Zzz(p1) > >> >Debug.Print "p1 = " & p1 > >> >End Sub > >> > > >> >From the Immediate window: > >> > > >> >zzz(12) > >> >p1 = 12 > >> > > >> >Good. > >> > > >> >I change the code as follows: > >> > > >> >Option Explicit > >> >Public Sub Zzz(p1, p2) > >> >Debug.Print "p1 = " & p1 > >> >End Sub > >> > > >> >Now from the immediate window: > >> > > >> >zzz(12,13) > >> > > >> >Causes: > >> > > >> >"Compiler error:" > >> > > >> >"Expected: =" > >> > > >> >What the heck is wrong? > >> > >> OK, I finally realized one problem, but created another. > >> > >> The "zzz(12,13)" statement fails because implicit calls to subs do not > >> use parentheses. So, I changed it to: > >> > >> zzz 12,13 > >> > >> This is in the Immediate window. Now I get a new error: > >> > >> Compile error: > >> > >> Expected variable or procedure, not project > >> > >> Huh? > >> > >> But if I put the exact same code into another sub, it works: > >> > >> > >> > >> Option Explicit > >> > >> Public Sub asd() > >> temp 12, 13 > >> End Sub > >> > >> Public Sub temp(p1, p2) > >> Debug.Print "p1 = " & p2 > >> End Sub > >> > >> Public Function zzz(p1, p2) > >> zzz = p1 + p2 > >> End Function > >> > >> > >> > >> Then in the Immediate window: > >> > >> asd > >> p1 = 13 > >> > >> > >> The "temp 12,13" works in one place, but not the other. Now I really > >> need to break something. > >> > >> -- > >> For email, use Usenet-20031220@spamex.com > > > >I wasn't able to reproduce your error. Likely because I didn't reproduce > >your exact steps. Not sure if this is what is happening in your case, but be > >aware the Intermediate Window can have a long memory. > > It turned out to be a stray DLL I had been fooling around with. My > mother always told me not to play with those kinds of DLLs, but would > I listen? Nooooooooo. > > >While playing you often need to stop and clear it out. > > By clear it out, do you mean Ctrl+A then Del? > > Or something like closing the project? > > -- > For email, use Usenet-20031220@spamex.com Download MZTools and save a few keystrokes... http://www.mztools.com/
.NOT My Views
Reverse Array order ? Cannot Load Form! RESET does what? Why can't I test class functions from the Immediate window? advanced tooltip bubbles question How should one form call another? Point me in the right direction - Mouse utility... Activex Exe How to handle data types in custom Max/Min function? |
|||||||||||||||||||||||