Nemeh Posted December 1, 2005 Posted December 1, 2005 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
eVAPor8 Posted December 1, 2005 Posted December 1, 2005 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
Nemeh Posted December 1, 2005 Author Posted December 1, 2005 Great thanks knew it was something simple been a while since I Autoit!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now