Sign in to follow this  
Followers 0
IvanCodin

InputBox Decect cancel Button

2 posts in this topic

How do I detect if the user presses the cancel button in an InputBox?

Here is what I am using now:

CODE
Func Telnet()

$ip = InputBox("IP", "Enter IP to connect to", @IPAddress1)

run("telnet " & $ip)

If @error Then

SplashTextOn("Notice - Error", " Your telnet command failed." & @CRLF & "No telent command avaliable.", 380,55)

Sleep(3000)

SplashOff()

EndIf

EndFunc

Thanks

CC

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Return Value

Success: Returns the string that was entered. Failure: Returns "" (blank string) and sets @error as follows: @Error 0 = The string returned is valid.

1 = The Cancel button was pushed.

2 = The Timeout time was reached.

3 = The InputBox failed to open. This is usually caused by bad arguments.

Just check if @Error equals 1.

Func Telnet()
$ip = InputBox("IP", "Enter IP to connect to", @IPAddress1)
if (@Error == 1) Then
    MsgBox(0, "", "canceled.")
    return 0
EndIf

run("telnet " & $ip)
If @error Then
SplashTextOn("Notice - Error", " Your telnet command failed." & @CRLF & "No telent command avaliable.", 380,55)
Sleep(3000)
SplashOff()
EndIf
EndFunc

Telnet()
Edited by cppman

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0