Supa Ben Posted December 30, 2007 Share Posted December 30, 2007 I'm making myself a program that will send ringtones to my phone. Here's an example of how I am trying to test if the number is a valid number. $number = "" Dim $NumError $test = NumCheck($number) If $test < 1 Then Msgbox(0,"",$NumError) Else MsgBox(0,"","Success") EndIf Func NumCheck($phonenumber) If $phonenumber = "" Then Return 0 & $NumError = "Error no number." Elseif $phonenumber < 10 Then Return -1 & $NumError = "Error put in Area Code also." Else Return 1 Endif EndFunc A messagebox appears signaling an error has happened but the $Numerror does not get set. I need help please. Link to comment Share on other sites More sharing options...
The Kandie Man Posted December 30, 2007 Share Posted December 30, 2007 You cannot do what you are doing in the return lines of the function. Instead, use a global error message string variable for all your functions. Then when a function of yours returns, have it set the value of the global $sErrorMsg. This would be analogous to the @error macro that autoit uses, but it would be a custom string version of the message. $number = "" Global $sErrorMsg $test = NumCheck($number) If $test < 1 Then Msgbox(0,"",$sErrorMsg) Else MsgBox(0,"","Success") EndIf Func NumCheck($phonenumber) If $phonenumber = "" Then $sErrorMsg = "Error no number." Return 0 Elseif $phonenumber < 10 Then $sErrorMsg = "Error put in Area Code also." Return -1 Else $sErrorMsg = "" Return 1 Endif EndFunc I believe that is what you want. - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Supa Ben Posted December 30, 2007 Author Share Posted December 30, 2007 The Kandie Man's Amazing fixThank you so much for that it works perfectly. Link to comment Share on other sites More sharing options...
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