Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-04-2006, 02:05 PM   PM User | #1
maxpouliot
New Coder

 
Join Date: Mar 2006
Posts: 90
Thanks: 2
Thanked 0 Times in 0 Posts
maxpouliot is an unknown quantity at this point
(Am i an idiot?)

Hi, can't get this very simple code to work (when i click on the outlook icon, nothing happens). Please help!

<SCRIPT LANGUAGE="VBScript">
sub ajouterOutlook(newdate,newpost)
MsgBox newdate
end sub
</script>

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


But this one works :

<SCRIPT LANGUAGE="VBScript">
sub ajouterOutlook(newdate)
MsgBox newdate
end sub
</script>

<A href=# onclick="ajouterOutlook('123')"><img align=bottom src="../../images/outlook.gif" border=0></A>
maxpouliot is offline   Reply With Quote
Old 04-04-2006, 02:09 PM   PM User | #2
WA
Administrator


 
Join Date: Mar 2002
Posts: 2,596
Thanks: 2
Thanked 19 Times in 18 Posts
WA will become famous soon enough
In the future, please use a more descriptive subject when posting a question. See posting guidelines.
__________________
- George
- JavaScript Kit- JavaScript tutorials and 400+ scripts!
- JavaScript Reference- JavaScript reference you can relate to.
WA is offline   Reply With Quote
Old 04-04-2006, 02:18 PM   PM User | #3
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
You cannot use parentheses when calling a sub. you should read the error messages that the browser gives you.

Code:
onclick="ajouterOutlook '123','456'">
Don't use VBScript. Use Javascript.
degsy is offline   Reply With Quote
Old 08-10-2009, 10:19 AM   PM User | #4
rukki
New to the CF scene

 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
rukki is an unknown quantity at this point
Code:
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
Char:91
Error: Cannot use parentheses when calling a Sub
Code:800A0414
The code is very simple, so I cannot understand what's wrong with it.

Last edited by rukki; 08-10-2009 at 10:20 AM.. Reason: Typo
rukki is offline   Reply With Quote
Old 08-10-2009, 07:40 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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:
Code:
...
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:
Code:
3 + 4
( 3 + 4 )
7 * ( 3 + 4 )
( 7 * ( 3 + 4 )
"test"
( "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:
Code:
msgbox "Some message"
But because of the rules of expressions you can also code
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:
Code:
msgbox "Some message", 0+16+4096
*AND* you could also call it thus:
Code:
msgbox ("Some message"), 0+16+4096
or thus:
Code:
msgbox "Some message", (0+16+4096)
or thus:
Code:
msgbox ("Some message"),(0+16+4096)
What you CAN NOT DO is call it thus:
Code:
msgbox ( "Some message", 0+16+4096 )
because
Code:
( "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:
Code:
CALL msgbox ( "Some message", 0+16+4096 )
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:25 AM.


Advertisement
Log in to turn off these ads.