Capture cancel in input box? 
Author Message
 Capture cancel in input box?

In VB I'd use StrPtr to get it.. how can I get the same in VBS? If input
= "" isn't really correct. Is there a FSO variant to StrPtr?

Something the Equivalent of this.

dim input
input = Inputbox("How many files would you like to create?")
if strptr(input)=0 then wscript.quit
   For i = 1 to input
         randomize
         j =  Round(rnd*1000,0)
              sFileSpec = "C:\win95\temp\test" & j & ".tmp"

Also if there is a way to get the windows directory and dump it into a
variable, could really use that too.. I'd use API to do it in VB but I
don't even want to try API in VBScript yet..

thanks..

Matt



Fri, 11 Oct 2002 03:00:00 GMT  
 Capture cancel in input box?
The cancel button returns a zero-length string.  

If the user clicks OK or presses ENTER, the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string ("").
http://msdn.microsoft.com/scripting/vbscript/doc/vsfctInputBox.htm

--
No support provided by e-mail!  Reply to the newsgroups only!
Regards,
Doug Knox, Microsoft MVPDTS
* Help us help YOU - http://members.home.com/dts-l/goodpost.htm
--
The Microsoft MVP Program does not constitute employment or contractual
obligation with Microsoft Corporation. We do this for fun! :)
--
Check out Doug's Windows 98 Tweaker
http://members.xoom.com/dbknox/registry/index.htm

Quote:

> In VB I'd use StrPtr to get it.. how can I get the same in VBS? If input
> = "" isn't really correct. Is there a FSO variant to StrPtr?

> Something the Equivalent of this.

> dim input
> input = Inputbox("How many files would you like to create?")
> if strptr(input)=0 then wscript.quit
>    For i = 1 to input
>          randomize
>          j =  Round(rnd*1000,0)
>               sFileSpec = "C:\win95\temp\test" & j & ".tmp"

> Also if there is a way to get the windows directory and dump it into a
> variable, could really use that too.. I'd use API to do it in VB but I
> don't even want to try API in VBscript yet..

> thanks..

> Matt



Fri, 11 Oct 2002 03:00:00 GMT  
 Capture cancel in input box?

The return value of the InputBox function is always equal to the
constant vbEmpty if the Cancel button or the ESC key is pressed. It is
never equal to vbEmpty if any other key or button is pressed. The
function below demonstrates this.

Function ButtonTest
      ButtonTest = InputBox("Click one of the buttons or " &_
                           "press either the ENTER or ESC key")
      If IsEmpty(ButtonTest) Then
          MsgBox "You clicked the Cancel button or " &_
                        "pressed the ESC key."
      Else
          MsgBox "You clicked the OK button or " &_
                        "pressed the Enter key."
      End If
End Function


: In VB I'd use StrPtr to get it.. how can I get the same in VBS? If
input
: = "" isn't really correct. Is there a FSO variant to StrPtr?
:
: Something the Equivalent of this.
:
: dim input
: input = Inputbox("How many files would you like to create?")
: if strptr(input)=0 then wscript.quit
:    For i = 1 to input
:          randomize
:          j =  Round(rnd*1000,0)
:               sFileSpec = "C:\win95\temp\test" & j & ".tmp"
:
: Also if there is a way to get the windows directory and dump it into
a
: variable, could really use that too.. I'd use API to do it in VB but
I
: don't even want to try API in VBscript yet..
:
: thanks..
:
: Matt
:



Fri, 11 Oct 2002 03:00:00 GMT  
 Capture cancel in input box?
Thanks everybody.. works great. I'll start using that in Vb as well

Matt



Sat, 12 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Cancel button on Input Box

2. Getting rid of the cancel button in input box

3. Capturing Input from Text Boxes

4. Cancel Input Box

5. Canceling an Input Box?

6. VB5: Canceling an input box...

7. VB5: Canceling an Input Box?

8. Testing for Cancel in Input Box

9. Input Box Cancel Command

10. Validating input from input box against an array of suitable inputs

11. Formatting date input in Input Box

12. Permission denied when using Input boxes and message boxes

 

 
Powered by phpBB® Forum Software