user8387622
user8387622

Reputation: 9

VBScript Function

I am a novice and have written a VBS Function but it keeps giving me an error. I have searched the MS site and the syntax looks correct. What is wrong? Here's what i've tried :

Function IsTheNumberTooLow()
IsTheNumberTooLow = intUserNumber < intRandomNo
MsgBox = "Your guess was too low. Try again", cGreetingMsg
End Function

Upvotes: 0

Views: 90

Answers (2)

Bug
Bug

Reputation: 528

Some of your syntax is incorrect. Also I am guessing your values are global, its best to pass in the values or set them inside the function. Try something like this:

Function IsTheNumberTooLow(intUserNumber, intRandomNo)
   Dim cGreetingMsg

   IsTheNumberTooLow = False
   cGreetingMsg = "Hello All"

   If intUserNumber < intRandomNo Then
      MsgBox "Your guess was too low. Try again", vbOKOnly, cGreetingMsg
      IsTheNumberTooLow = True
   End If
End Function

Upvotes: 2

jcpaiva
jcpaiva

Reputation: 422

Do you assign a value to cGreetingMsg elsewhere? And intUserNumber or intRandomNo?

Upvotes: 0

Related Questions