Hello All,

I am new to VBScript and was hoping for some pointers. Basically, I created
a DOS batch file at work that allows us to install several software packages
in order after we tell it which drive to launch the packages from. The DOS
batch file works like a dream, however, I would like to use VBScript to take
this to the next level. I have figured out how to do certain things like
display system specs and stuff like that, but some of the basic concepts are
giving me problems. Here are the questions I have:

1. After setting up an Input Box that has the buttons OK and Cancel, how
can I program the script to exit the program if the button Cancel is
pressed? As it stands right now, regardless if the OK or Cancel button is
pressed, the script will carry on to the next line of code.

2. In the DOS batch file, I was easily able to set up labels and tell DOS
if a certain condition was met, goto label, If condition wasn't met goto
this label. Basically, I was easily able to direct my script to jump to
different parts of my code just by using the goto xxxx. Can I do this in
VBScript? Right now, it seems like the Select Case and Do Loops just
doesn't fit my needs but that is probably because I don't know how to use
them properly for what I am trying to do.

3. I am currently using NotePad to develop my scripts and it is ok for the
most part. However, if I run the program and receive an error in line 77, I
have to count all the way down just to find out the line. Please tell me
there is a better way! Right now I have decided to break my code down into
sections and run one part at a time in seperate scripts just to see if it
works.

4. Is there a way that I can display colored text in a message box? The
goal is to have the system specs displayed and if any part of the system
specs doesn't meet my software requirements, then I want it to display
additional text (that is red) pointing this out.

Any help or advise would be appreciated. Thanks in advance!

RE: A few questions for you VBScript Gurus!!! by NickB

NickB
Sun Jul 18 20:42:01 CDT 2004



"Kojak" wrote:

> Hello All,
>
> I am new to VBScript and was hoping for some pointers. Basically, I created
> a DOS batch file at work that allows us to install several software packages
> in order after we tell it which drive to launch the packages from. The DOS
> batch file works like a dream, however, I would like to use VBScript to take
> this to the next level. I have figured out how to do certain things like
> display system specs and stuff like that, but some of the basic concepts are
> giving me problems. Here are the questions I have:
>
> 1. After setting up an Input Box that has the buttons OK and Cancel, how
> can I program the script to exit the program if the button Cancel is
> pressed? As it stands right now, regardless if the OK or Cancel button is
> pressed, the script will carry on to the next line of code.

Check = Msgbox ("Your question, 36, "Some title")
if Check = 6 then
code for what you want to happen if it is yes
elseif Check = 7 then
code you want if it is no
end if

>
> 2. In the DOS batch file, I was easily able to set up labels and tell DOS
> if a certain condition was met, goto label, If condition wasn't met goto
> this label. Basically, I was easily able to direct my script to jump to
> different parts of my code just by using the goto xxxx. Can I do this in
> VBScript? Right now, it seems like the Select Case and Do Loops just
> doesn't fit my needs but that is probably because I don't know how to use
> them properly for what I am trying to do.

Use subroutines
>
> 3. I am currently using NotePad to develop my scripts and it is ok for the
> most part. However, if I run the program and receive an error in line 77, I
> have to count all the way down just to find out the line. Please tell me
> there is a better way! Right now I have decided to break my code down into
> sections and run one part at a time in seperate scripts just to see if it
> works.
>

Depending on the OS....there is a Microsoft Scrip Editor in the office suite...file name: mse7.exe
Not the best but far better than notepad.

> 4. Is there a way that I can display colored text in a message box? The
> goal is to have the system specs displayed and if any part of the system
> specs doesn't meet my software requirements, then I want it to display
> additional text (that is red) pointing this out.
>
I couldnt help you with that. I placed all my system specs into an Excel spreadsheet.

> Any help or advise would be appreciated. Thanks in advance!
>
>
>

Re: A few questions for you VBScript Gurus!!! by McKirahan

McKirahan
Mon Jul 19 05:40:49 CDT 2004

"NickB" <NickB@discussions.microsoft.com> wrote in message
news:8BACF584-35A0-4BC4-B756-9FCAC3803006@microsoft.com...
>
>
> "Kojak" wrote:
>
> > Hello All,
> >
> > I am new to VBScript and was hoping for some pointers. Basically, I
created
> > a DOS batch file at work that allows us to install several software
packages
> > in order after we tell it which drive to launch the packages from. The
DOS
> > batch file works like a dream, however, I would like to use VBScript to
take
> > this to the next level. I have figured out how to do certain things
like
> > display system specs and stuff like that, but some of the basic concepts
are
> > giving me problems. Here are the questions I have:
> >
> > 1. After setting up an Input Box that has the buttons OK and Cancel,
how
> > can I program the script to exit the program if the button Cancel is
> > pressed? As it stands right now, regardless if the OK or Cancel button
is
> > pressed, the script will carry on to the next line of code.
>
> Check = Msgbox ("Your question, 36, "Some title")
> if Check = 6 then
> code for what you want to happen if it is yes
> elseif Check = 7 then
> code you want if it is no
> end if

[snip]

Dim strBOX
strBOX = InputBox("Hello World","InputBox Title")
If strBOX = "" Then
MsgBox "Cancel or No Input."
Else
MsgBox "OK; Input = " & strBOX
End If

MsgBox will allow you to test the value of the button clicked; you can test
for constants instead of numbers; for example, vbYes and vbNo. I don't
believe you can test the value of the button clicked for an InputBox.



Re: A few questions for you VBScript Gurus!!! by Michael

Michael
Mon Jul 19 18:38:19 CDT 2004


"Kojak" <kojak2k4@sbcglobal.net> wrote in message news:uT%23b0pQbEHA.2908@TK2MSFTNGP10.phx.gbl...
: Hello All,
:
: I am new to VBScript and was hoping for some pointers. Basically, I created
: a DOS batch file at work that allows us to install several software packages
: in order after we tell it which drive to launch the packages from. The DOS
: batch file works like a dream, however, I would like to use VBScript to take
: this to the next level. I have figured out how to do certain things like
: display system specs and stuff like that, but some of the basic concepts are
: giving me problems. Here are the questions I have:
:
: 1. After setting up an Input Box that has the buttons OK and Cancel, how
: can I program the script to exit the program if the button Cancel is
: pressed? As it stands right now, regardless if the OK or Cancel button is
: pressed, the script will carry on to the next line of code.


dim response

do while response = ""
response = InputBox("enter something")
if IsEmpty(response) then
msgbox "cancel/escape/x button selected"
wscript.quit
elseif response = "" then
msgbox "OK button selected, but nothing entered - try again"
else
msgbox "OK button selected, you entered: " & response
end if
loop

msgbox "continuing with code...."



Re: A few questions for you VBScript Gurus!!! by Al

Al
Wed Jul 21 19:21:35 CDT 2004


"NickB" <NickB@discussions.microsoft.com> wrote in message
news:8BACF584-35A0-4BC4-B756-9FCAC3803006@microsoft.com...
>
>
> "Kojak" wrote:
>
> > Hello All,
> >
> > I am new to VBScript and was hoping for some pointers. Basically, I
created
> > a DOS batch file at work that allows us to install several software
packages
> > in order after we tell it which drive to launch the packages from. The
DOS
> > batch file works like a dream, however, I would like to use VBScript to
take
> > this to the next level. I have figured out how to do certain things
like
> > display system specs and stuff like that, but some of the basic concepts
are
> > giving me problems. Here are the questions I have:
> >
> > 1. After setting up an Input Box that has the buttons OK and Cancel,
how
> > can I program the script to exit the program if the button Cancel is
> > pressed? As it stands right now, regardless if the OK or Cancel button
is
> > pressed, the script will carry on to the next line of code.
>
> Check = Msgbox ("Your question, 36, "Some title")
> if Check = 6 then
> code for what you want to happen if it is yes
> elseif Check = 7 then
> code you want if it is no
> end if

I'd use the pre-defined constants vbyes and vbno, as this makes the code
easier to read. I also prefer select case over if-then-elseif-etc, as I feel
that is a more intuitive way to model this type of a conditional. But then,
that is a personal preference thing.

> >
> > 2. In the DOS batch file, I was easily able to set up labels and tell
DOS
> > if a certain condition was met, goto label, If condition wasn't met
goto
> > this label. Basically, I was easily able to direct my script to jump to
> > different parts of my code just by using the goto xxxx. Can I do this
in
> > VBScript? Right now, it seems like the Select Case and Do Loops just
> > doesn't fit my needs but that is probably because I don't know how to
use
> > them properly for what I am trying to do.
>
> Use subroutines

... and try to use GOTO in batch only where absolutely necessary. Also, use
subroutines in batch, i.e.:

call:sub1
call:sub2
goto:eof
:sub1
echo/in sub1
goto:eof
:sub2
echo/in sub2
goto:eof

(Disclaimer: WinNT variants only, not Win9X)

> > 3. I am currently using NotePad to develop my scripts and it is ok for
the
> > most part. However, if I run the program and receive an error in line
77, I
> > have to count all the way down just to find out the line. Please tell
me
> > there is a better way! Right now I have decided to break my code down
into
> > sections and run one part at a time in seperate scripts just to see if
it
> > works.
> >
>
> Depending on the OS....there is a Microsoft Scrip Editor in the office
suite...file name: mse7.exe
> Not the best but far better than notepad.

PrimalScript is a good one, but it's not free, and is not the cheapest
script editor out there.

>
> > 4. Is there a way that I can display colored text in a message box?
The
> > goal is to have the system specs displayed and if any part of the system
> > specs doesn't meet my software requirements, then I want it to display
> > additional text (that is red) pointing this out.
> >
> I couldnt help you with that. I placed all my system specs into an Excel
spreadsheet.

MSGBOX has only the variations noted in the docs, i.e. the text field, an
optional icon, and a number of possible button combinations, any of which
can be made the default. Missing is colour, font, non-standard buttons, and
etc.

/Al