Jump to content

Send inputbox variable to ping function


Nemeh
 Share

Recommended Posts

Is it possible to send a variable from user inputbox to the ping function? I have coded the following mostly by using the examples in the help file but after I type in a IP it returns error number 4 which is other error.

#Region --- CodeWizard generated code Start ---
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Width=50, Height=50
;If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer
Dim $sInputBoxAnswer, $var
$sInputBoxAnswer = InputBox("Quick Pinger","Enter the server IP:",""," ","50","50","-1","-1")
Select
   Case @Error = 0;OK - The string returned is valid
   Case @Error = 1;The Cancel button was pushed
   Case @Error = 3;The InputBox failed to open
EndSelect
#EndRegion --- CodeWizard generated code End ---
$var = Ping("$sInputBoxAnswer",250)
If $var Then; also possible:  If @error = 0 Then ...
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured. Code: " & @error)
EndIf

The ;If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer is commented out as it always causes errors.

Nemeh

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...