Need some help with VBScript.

1 replies
Hey guys well this is not my usual thread on here but I am going back to school and have a class that is over VBscript. Anyway I have an asignment that is kicking my butt for some reason. I will post the instructions for this section of code then list what I have written out.

Instructions:

Do
Display Message
"Do you wish to Display all of the IP Addresses (Y/N) ..... "
Get User Response and assign it to variable ans
If ans isn't "Y" & ans isn't "y" & ans isn't "N" & ans isn't "n" Then
Beep Speaker Twice
Display Msg "Error, Y,y,N,n response Only!!!" & skip line
EndIf
Loop While ans isn't "Y" & ans isn't "y" & ans isn't "N" & ans isn't "n"

If ans is "Y" OR ans is "y" Then
skip line
For roomNum = 0 to 5
For compNum = 0 to 3
Display "The IP Address in Room " room+100 " for Computer "
computer+1 " is " ipAddress(room,computer)
EndFor
EndFor
EndIf


And here is my code: The issue is that no matter what character you enter when prompted to enter Y or N, is that it responds with the error message. Which is Error, Y,y,N,n Response Only!!!!. Any help with this I would greatly appreciate.

Do
WScript.StdOut.Write(" Do you wish to Display all of the IP Addresses (Y/N) ..... ")
ans = WScript.StdIn.Readline()

If ans <> Y AND ans <> y AND ans <> N AND ans <> n Then
WScript.StdOut.WriteLine(chr(7) & chr(7) & " Error, Y,y,N,n Response Only!!!!! " & vbCrlf)
End If


Loop While ans <> Y OR ans <> y OR ans <> N OR ans <> n

If ans = Y OR ans = y Then
WScript.StdIn.Read(1)
For room = 0 to 5
For computer = 0 to 3
WScript.StdOut.Write("The IP Address in Room " & room+100 & " for Computer " & computer+1 & _
"is" & ipAddress(room, computer))

Next
Next

End If
#vbscript
  • Profile picture of the author Jason Zalesky
    Nevermind I finally got it figured out. Instructor is asking for something we couldnt do with his instructions so had to go a different route. Thanks.
    {{ DiscussionBoard.errors[5920311].message }}

Trending Topics