Sign in to follow this  
Followers 0
Nemeh

Send inputbox variable to ping function

3 posts in this topic

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

Share this post


Link to post
Share on other sites



You're sending the Literal to the ping function... Change

$var = Ping("$sInputBoxAnswer",250)

to

$var = Ping($sInputBoxAnswer,250)

Oh and BTW, you arn't forced to use the IP, for instance www.google.com will also work

Share this post


Link to post
Share on other sites

Great thanks knew it was something simple :P been a while since I Autoit!

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