View Full Version : (Am i an idiot?)

04-04-2006, 03:05 PM
Hi, can't get this very simple code to work (when i click on the outlook icon, nothing happens). Please help!

sub ajouterOutlook(newdate,newpost)
MsgBox newdate
end sub

<A href=# onclick="ajouterOutlook('123','456')"><img align=bottom src="../../images/outlook.gif" border=0></A>

But this one works :

sub ajouterOutlook(newdate)
MsgBox newdate
end sub

<A href=# onclick="ajouterOutlook('123')"><img align=bottom src="../../images/outlook.gif" border=0></A>

04-04-2006, 03:09 PM
In the future, please use a more descriptive subject when posting a question. See posting guidelines. (http://www.codingforums.com/postguide.htm)

04-04-2006, 03:18 PM
You cannot use parentheses when calling a sub. you should read the error messages that the browser gives you.

onclick="ajouterOutlook '123','456'">

Don't use VBScript. Use Javascript.

08-10-2009, 11:19 AM
msgbox("A sega, kak da si napravite virus")
msgbox("Otvorete faila Q.txt")
msgbox("Zamenete 1 s kakvoto iskate da pishe, da kajem, blabla")
msgbox("A sega, zatvorete faila i promenete imeto mu ot Q.txt na Q.vbs")
msgbox("Slojete na miastoto na 0 4 i go pusnete. Sega si imate da ili ne. No nishto ne stava.")
msgbox("Imate nujda ot konstrukciata If.")
msgbox("Desen klik na Q.vbs -> Edit.")
msgbox("Sega, na sledvashtia red napishete if x=VbYes then.")
msgbox("Napishete si vtori msgbox, samo che x stava na y.")
msgbox("Napishete si EndIf na sledvasht red. Prosto, nali?")
msgbox("No eto kakvo mojete da napravite. Na miastoto na 2 napishete 2+4. Ne 6, a 2+4. Pusnete programkata.")
msgbox("No vijte vsichki vuzmojni komandi tam:")
msgbox(" Tova e strukturata na msgbox: MsgBox skoba Prompt, Buttons skoba ")
msgbox("Na miastoto na Prompt si pishete kakvoto iskate da pokazva prozoreca kakto e tozi tekst")
msgbox("Na miastoto na Buttons pishete sbor at kodove:")
msgbox(" O e samo za 0K, 1 e za OK i Cancel, 2 e za Abort, Retry, Ignore")
msgbox(" 3 e za Yes,No,Cancel, 4 e za Yes,No, 5 e za Retry, Cancel.")
msgbox("Ako iskate da izpolzvate if, eto vi konstantite: VBOK=OK,VBCancel=Cancel")
msgbox("VBAbort=Abort,VBRetry=Retry,VBIgnore=Ignore,VBYes=Yes i VBNo=No")
msgbox("No ima oshte mnogo chisla za kartinki:16,32,48,64. Probvaite gi!")
msgbox("Ako iskate da ne mogat da se izpolzvat drugi programi-4096.")
msgbox("Mnogo vajno e da slagate kodovete vuv viarnata posledovatelnost.")
msgbox("I eto nai gadnoto: naprravete oshte edin msgbox.")
msgbox("Na reda pred nego napishete do, na reda sled msgbox-a loop, a na sledvashia red - EndLoop.")
msgbox("Predi da pusnete, znaite che triabva TaskManager, za da se spre tova", 0+16+4096)
msgbox("E, dovolni li ste?", 4, "Krai")
msgbox("Vijte koda za oshte edna hitrinka. Vidiahte li krai na poslednoto?")

The text in the quotation marks is in another language, but here's what the compiler displays:
Line: 25
Error: Cannot use parentheses when calling a Sub
The code is very simple, so I cannot understand what's wrong with it.

Old Pedant
08-10-2009, 08:40 PM
Just EXACTLY what the message says:

In VBScript, the call to MSGBOX is *NOT* a function call. It is a call to a SUB.

And, again, when you call a SUB, you are *NOT* supposed to use parentheses! Period.

So *techinically*, ALL of your code there is WRONG. None of those calls should use ANY parentheses:

msgbox "Na reda pred nego napishete do, na reda sled msgbox-a loop, a na sledvashia red - EndLoop."
msgbox "Predi da pusnete, znaite che triabva TaskManager, za da se spre tova", 0+16+4096

Why does the code SOMETIMES work? Because of the definition of an *EXPRESSION*.

In VBScript, as in most computer languages, any expression can become a sub-expression by putting parentheses around it:

3 + 4
( 3 + 4 )
7 * ( 3 + 4 )
( 7 * ( 3 + 4 )
( "test" )
"test" & 3.1415
( "test" & 3.1415 )

ALL of those are legal expressions. But the ones in red have *extra* parentheses around them. The parentheses don't hurt, but they aren't needed.

So you *CAN* code simply:

msgbox "Some message"

But because of the rules of expressions you can also code

msgbox ("Some message")

It is important to understand that the parentheses there are *NOT* part of the msgbox call! They are *ONLY* part of the expression!

Now, when you need to call with more than one argument, you *CAN* call it thus:

msgbox "Some message", 0+16+4096

*AND* you could also call it thus:

msgbox ("Some message"), 0+16+4096

or thus:

msgbox "Some message", (0+16+4096)

or thus:

msgbox ("Some message"),(0+16+4096)

What you CAN NOT DO is call it thus:

msgbox ( "Some message", 0+16+4096 )


( "Some message", 0+16+4096 )

is *NOT* an expression!!!

Strangely enough, VBScript *DOES* have a way for you to treat a SUB *as if* it is a function:

CALL msgbox ( "Some message", 0+16+4096 )