Results 1 to 10 of 10

Thread: Mesage Box in VB Script (Extreamly easy)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I have absoulutly NO clue on VB script, I would apprecitate it if someone can give me code for my website so that when the page loads, a messagebox comes up saying "Hello and Welcome to my Website" then they click OK and then another message box comes up saying "The last update was held on 9/23/00" then they click ok, and the brower window closes, please give me complete source on how to do this.

    I dont even know how to do somehting like <lan id= vbscript> is that correct? if not please tell me how to do that


    thanks in advance

    Dimava
    NXSupport - Your one-stop source for computer help

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Gig Harbor, WA; Posts: 89950
    Posts
    360
    Without you knowing vbscript, the only advice I can give you is go here:

    http://splendor.unibe.ch/programming/vbs/vbshtml.htm

    A tutorial on vbscript for html.
    Other than that, perhaps Javascript?????

    Sorry!
    Lee
    Mahalo
    VB6(SP5), VC++, COBOL, Basic, JAVA
    MBA, MCSD, MCSE, A+
    Computer Forensics

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Just do a msgbox:
    Code:
    Msgbox("Hello world!")
    To add vbscript to an html file, you can use the Activex Control Pad from Micro$oft:http://www.mediabuilder.com/462.html

  4. #4
    Guest
    Why don't you just use Javascript?

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    alert("Hello World!")
    </SCRIPT>

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks guys, I would rather user VB becuase I haven't start learning JAVA yet, and I'm more comfortable with VB. Once again, thanks guys
    NXSupport - Your one-stop source for computer help

  6. #6
    Guest
    Actually, it is:

    msgbox("Prompt", paremeters(the same as VB), "Title")

    JAVASCRIPT can only display ALERT & CONFIRM

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    would this work in VB Script:

    Code:
    Dim inta as integer
    inta = MsgBox ("Do you Like my website", VbYesNo, "WAZZZZUP")
    if inta = 6 then
    MsgBox "Thanks, I'm glad you like this"
    Else
    inta = 7 then
    MsgBox "Whats wrong with it?, email [email protected]"
    end if
    end if
    NXSupport - Your one-stop source for computer help

  8. #8
    Guest
    Ok. Calm down...it was just a suggestion.

    I guess VB Script would be better since you can have the icon you choose and the title you want. And Javascript doesn't have that option.

  9. #9
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    Here is how you would do what you want in vbscript:

    Code:
    <html>
    <head>
    <script language="vbscript">
    sub MSG()
    'All variables are variant type.  If you need a particular
    'type of variable, you have to use one of the follow functions
    'to convert type: CStr, CLng, CBool, CInt (I think this is right).
    Dim lret
    lret=msgbox("hi, you are at my site.", vbokcancel, "MY Site")
    if lret=1 then
    	msgbox "document was last modified: " & document.lastmodified
    end if
    end sub
    </script>
    </head>
    <body onload="MSG()">
    hi
    </body>
    </html>
    As to your last question. You cannot close the parent window of a webbrowser, without the users explicitly allowing it. The command you would use is:

    Code:
    self.close 'or document.close
    If you try this in the parent window, an alert message will be displayed to the users warning them that a script is trying to close their browser. However, if this is on a child window (a new window spawned by the webpage), then you can use the method above to automatically close it.

    Now remember, this will only work in IE, so if you are looking for cross browser compatibility, you would want to change it to javascript, like this:

    Code:
    <html>
    <head>
    <script language="javascript">
    
    function MSG() {
    var lret;
    lret=confirm("hi, you are at my site.","MY Site");
    
    if (lret){
    	alert("document was last modified: " + document.lastModified);
    }
    }
    </script>
    </head>
    <body onload="MSG();">
    hi
    </body>
    </html>
    I personally always use either javascript or php, because I know that most browsers can handle it in some form or another. Anyway, just my 2 cents. Hope this helps.


  10. #10
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    The msgbox function is not available in client side VBScript. Only on the server side where it is undesirable to have a modal dialog pop up. (And pointless since nobody's there to read it)

    You have to use window.alert. The syntax is pretty much the same in VBScript as it is in Javascript.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width