Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2006, 02:10 PM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBScript

Hi, i am new to vbscript and brought the vbscript book.
I just needed to know why the following code does not work properly.
It's on page 14.
------------------------------------------------------
Dim Greeting
Dim YourName
Dim TryAgain

Do

   TryAgain = "No"

      YourName = InputBox("Please enter your name:")

      If YourName = "" Then
      MsgBox "You must enter your name to continue."
   TryAgain = "Yes"
 Else
      Greeting = "Hello, " & YourName & ", great to meet you."
 End If

Loop While TryAgian = "Yes"

MsgBox Greeting

------------------------------------------------------------------

The code does not seem to start again from the begining when i dont enter any input. I get the first MsgBox and then when i click "ok" i get a second MsgBox with no message. When i click "ok" it just closes and nothing else seems to happen.

Can anyone tell me why this is?


 
Old September 26th, 2006, 12:38 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

YUP!!! done with changes. IT WORKS.

Dim Greeting
Dim YourName
Dim TryAgain

Do
TryAgain = "No"
YourName = InputBox("Please enter your name:")

If YourName = "" Then
    MsgBox "You must enter your name to continue."
    TryAgain = "Yes"
Else
    Greeting = "Hello, " & YourName & ", great to meet you."
    exit do
End If
Loop Until TryAgian = "Yes"

MsgBox Greeting

With Regards,
Raghavendra Mudugal
 
Old September 26th, 2006, 07:44 AM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Raghavendra_Mudugal. It is works perfectly.


 
Old September 27th, 2006, 03:06 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Code:
    Dim YourName
    YourName = ""

    Do Until YourName <> ""
        YourName = InputBox("Please enter your name:")

        If YourName = "" Then
            MsgBox "You must enter your name to continue."
        End If
    Loop

   MsgBox "Hello " & YourName & ", great to meet you."





Similar Threads
Thread Thread Starter Forum Replies Last Post
VBSCRIPT pantera710 Classic ASP Basics 3 September 11th, 2006 09:28 PM
Need Help in VBScript ragavendran31 Pro VB 6 0 April 19th, 2006 05:54 AM
Using VBScript and JSScript together? hayley02 Classic ASP Professional 2 June 7th, 2004 01:25 PM
Using JScript with VBScript jwalborn Javascript How-To 4 October 13th, 2003 10:07 AM
Using VBScript and JavaScript together jwalborn Classic ASP Professional 2 October 13th, 2003 10:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.