Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2006
    Thanked 0 Times in 0 Posts

    (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!

    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>

  • #2
    Senior Coder
    Join Date
    Mar 2002
    Thanked 19 Times in 18 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Nov 2002
    North-East, UK
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Aug 2009
    Thanked 0 Times in 0 Posts
    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.
    Last edited by rukki; 08-10-2009 at 10:20 AM. Reason: Typo

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,912 Times in 4,873 Posts
    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 )


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts