I have the following script and at the end I want to prompt the user
with a MsgBox to validate their entries. Two things:
1) How do I pass the values they entered into the msgbox?
2) I have added the yes/no option buttons but don't want cancel to be
included. I want the yes button to end the script as it does, but if
they select no, I want the script to run from the top.

Here is my mess


Dim strReturnVal1, strReturnVal2, strReturnVal3, strName, strKeyName,
strType
Dim g_objShell :Set g_objShell = createobject("WScript.Shell")
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\LLNL"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath







strName = "HKEY_LOCAL_MACHINE\SOFTWARE\LLNL" 'Change path to correct
location.
strKeyName = "\DOE #"
strtype = "REG_SZ"

GetUserInput strReturnVal1


'//Add your code here to put strReturnVal1 into reg!
g_objShell.RegWrite strname & strKeyName, strReturnVal1,strType


' User Input Function
Sub GetUserInput(strReturnVal1)
Dim strChoice1
strChoice1 = InputBox("Please input Machine DOE #")


If strChoice1 = "" Then
'Flag an Error is Null
strReturnVal1 = "BAD Usage"
else
strReturnVal1 = strChoice1
end if
End Sub






strName = "HKEY_LOCAL_MACHINE\SOFTWARE\LLNL" 'Change path to correct
location.
strKeyName = "\Building"
strtype = "REG_SZ"


GetUserInputa strReturnVal2


'//Add your code here to put strReturnVal into reg!
g_objShell.RegWrite strname & strKeyName, strReturnVal2,strType


' User Input Function
Sub GetUserInputa(strReturnVal2)
Dim strChoice2
strChoice2 = InputBox("Please input Building #")


If strChoice2 = "" Then
'Flag an Error is Null
strReturnVal2 = "BAD Usage"
else
strReturnVal2 = strChoice2
end if
End Sub


strName = "HKEY_LOCAL_MACHINE\SOFTWARE\LLNL" 'Change path to correct
location.
strKeyName = "\Room"
strtype = "REG_SZ"


GetUserInputb strReturnVal3


'//Add your code here to put strReturnVal3 into reg!
g_objShell.RegWrite strname & strKeyName, strReturnVal3,strType


' User Input Function
Sub GetUserInputb(strReturnVal3)
Dim strChoice3
strChoice3 = InputBox("Please input Room #")


If strChoice3 = "" Then
'Flag an Error is Null
strReturnVal3 = "BAD Usage"
else
strReturnVal3 = strChoice3
end if
End Sub


Dim MyVar
MyVar = MsgBox ("Is the data you entered correct?" & vbcrlf & "DOE #" &
vbcrlf & "Building #" & vbcrlf & "Room #",67,"CMS ISTeam")

Re: MsgBox Question by Torgeir

Torgeir
Thu Jan 27 15:37:53 CST 2005

mint_fo@yahoo.com wrote:
> I have the following script and at the end I want to prompt the user
> with a MsgBox to validate their entries. Two things:
> 1) How do I pass the values they entered into the msgbox?
> 2) I have added the yes/no option buttons but don't want cancel to be
> included. I want the yes button to end the script as it does, but if
> they select no, I want the script to run from the top.
>
> Here is my mess
> (snip)
Hi,


'--------------------8<----------------------
Do
strReturnVal1 = "1234"
strReturnVal2 = "4"
strReturnVal3 = "3"

iRC = MsgBox("Is the data you entered correct?" & vbCrLf & vbCrLf _
& "DOE #" & strReturnVal1 & vbCrLf _
& "Building #" & strReturnVal2 & vbCrLf _
& "Room #" & strReturnVal3 & vbCrLf _
& vbCrLf, vbYesNo, "CMS ISTeam")

Loop Until iRC = vbYes

WScript.Echo "Finished"

'--------------------8<----------------------



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: MsgBox Question by mint_fo

mint_fo
Thu Jan 27 16:37:49 CST 2005

Thank you very much for the quick reply. A couple of questions. When
you assign static characters to streturnval, that will undo what the
user input from earlier in the code. Also the loop will continue to
run the msgbox and not the entire script if "no" right?
I am kinda confused by the code I guess



orgeir Bakken (MVP) wrote:
> mint_fo@yahoo.com wrote:
> > I have the following script and at the end I want to prompt the
user
> > with a MsgBox to validate their entries. Two things:
> > 1) How do I pass the values they entered into the msgbox?
> > 2) I have added the yes/no option buttons but don't want cancel to
be
> > included. I want the yes button to end the script as it does, but
if
> > they select no, I want the script to run from the top.
> >
> > Here is my mess
> > (snip)
> Hi,
>
>
> '--------------------8<----------------------
> Do
> strReturnVal1 = "1234"
> strReturnVal2 = "4"
> strReturnVal3 = "3"
>
> iRC = MsgBox("Is the data you entered correct?" & vbCrLf & vbCrLf
_
> & "DOE #" & strReturnVal1 & vbCrLf _
> & "Building #" & strReturnVal2 & vbCrLf _
> & "Room #" & strReturnVal3 & vbCrLf _
> & vbCrLf, vbYesNo, "CMS ISTeam")
>
> Loop Until iRC = vbYes
>
> WScript.Echo "Finished"
>
> '--------------------8<----------------------
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx


Re: MsgBox Question by Torgeir

Torgeir
Thu Jan 27 16:52:16 CST 2005

mint_fo@yahoo.com wrote:

> Thank you very much for the quick reply. A couple of questions.
> When you assign static characters to streturnval, that will undo
> what the user input from earlier in the code.

My code was just a "conceptual" example script. You would of course
need to put your code that asks for the user input inside the loop
(replacing my hard coding).

Note that you need to keep your Sub/Function definitions outside the
loop. Put all your Subs/Functions all the way down at the bottom of
the script.


> Also the loop will continue to
> run the msgbox and not the entire script if "no" right?

Well, that depends on how much of your existing code you put inside
the loop. That is up to you, depending how much code you need to
re-run if the user selects "No".



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx