Jacob Loperson
asked on
VBSScript Error IP Array
Can anyone tell me what is wrong with this script it keeps giving me an error on line 84
' Below is an initialize a 2-dimension
' array of IP Address. The first index
' +100 is the room# and the second index
' +1 is the computer# in the room.
dim ipAddress(5,3)
ipAddress(0,0)="192.168.10.11"
ipAddress(0,1)="192.168.10.12"
ipAddress(0,2)="192.168.10.13"
ipAddress(0,3)="192.168.10.14"
ipAddress(1,0)="192.168.10.19"
ipAddress(1,1)="192.168.10.20"
ipAddress(1,2)="192.168.10.21"
ipAddress(1,3)="192.168.10.22"
ipAddress(2,0)="192.168.10.27"
ipAddress(2,1)="192.168.10.28"
ipAddress(2,2)="192.168.10.29"
ipAddress(2,3)="192.168.10.30"
ipAddress(3,0)="192.168.10.35"
ipAddress(3,1)="192.168.10.36"
ipAddress(3,2)="192.168.10.37"
ipAddress(3,3)="192.168.10.38"
ipAddress(4,0)="192.168.10.43"
ipAddress(4,1)="192.168.10.44"
ipAddress(4,2)="192.168.10.45"
ipAddress(4,3)="192.168.10.46"
ipAddress(5,0)="192.168.10.51"
ipAddress(5,1)="192.168.10.52"
ipAddress(5,2)="192.168.10.53"
ipAddress(5,3)="192.168.10.54"
'Define program variables
roomStr=""
compStr=""
roomNum=0
compNum=0
ans = ""
Do
WScript.Echo "Please Enter A Room Number (100-105) ...... "
roomStr = WScript.StdIn.ReadLine
If IsNumeric(roomStr) Then
If (roomStr >= 100) And (roomStr <= 105) Then Exit Do
End If
WScript.Echo Chr(7)
WScript.Echo Chr (7)
WScript.Echo "Error, 100 to 105 Only!!!"
Loop
Do
WScript.Echo "Please Enter The Computer Number (1-4) ......"
compStr = WScript.StdIn.ReadLine
If IsNumeric(compStr) Then
If (compStr >= 1) And (compStr <4) Then Exit Do
End If
WScript.Echo Chr (7)
WScript.Echo Chr (7)
WScript.Echo "Error, 1 to 4 Only!!!"
Loop
'Display All IP Addresses Y/N?
Do
WScript.StdOut.Write("Do you wish to Display all of the IP Address Y/N......")
Ans = WScript.StdIn.ReadLine()
If Ans <> "Y" And ans <> "y" And ans <> "N" And ans <> "n" Then
WScript.StdOut.Write Chr (7)
WScript.StdOut.Write Chr (7)
WScript.Write "Error,Y,y,N,n Responses Only!!!"
End If
Loop While ans <> "N" And ans <> "n" And ans <> "Y" And ans <> "y"
If ans = "Y" Or ans = "y" Then
For RoomNum = 0 To 5
For CompNum = 0 To 3
WScript.Echo "The IP Address in Room " & roomNum+100 & " for computer " & compnum+1 & " is " & ipAddress(roomNum,compNum)
Next
Next
End If
If Ans = "N" Or ans = "n" Then
WScript.Echo " The IP Address In Room " & roomStr & " for computer " & compStr " is " & IpAddress(roomNum,compNum)
End If
You're missing an end if.
btw, instead of checking for both upper and lower cases of y and n you case use either the UCase function or the LCase function.
If UCase(Ans) = "N" Then
If UCase(Ans) = "Y" Then
or If LCase(Ans) = "n" Then
If LCase(Ans) = "y" Then
ASKER
Missing an end if where?
Line 84, of course ;~)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That wasn't the only error...
For example line 60
For example line 60
Option Explicit
' Below is an initialize a 2-dimension
' array of IP Address. The first index
' +100 is the room# and the second index
' +1 is the computer# in the room.
Dim ipAddress(5,3)
ipAddress(0,0)="192.168.10.11"
ipAddress(0,1)="192.168.10.12"
ipAddress(0,2)="192.168.10.13"
ipAddress(0,3)="192.168.10.14"
ipAddress(1,0)="192.168.10.19"
ipAddress(1,1)="192.168.10.20"
ipAddress(1,2)="192.168.10.21"
ipAddress(1,3)="192.168.10.22"
ipAddress(2,0)="192.168.10.27"
ipAddress(2,1)="192.168.10.28"
ipAddress(2,2)="192.168.10.29"
ipAddress(2,3)="192.168.10.30"
ipAddress(3,0)="192.168.10.35"
ipAddress(3,1)="192.168.10.36"
ipAddress(3,2)="192.168.10.37"
ipAddress(3,3)="192.168.10.38"
ipAddress(4,0)="192.168.10.43"
ipAddress(4,1)="192.168.10.44"
ipAddress(4,2)="192.168.10.45"
ipAddress(4,3)="192.168.10.46"
ipAddress(5,0)="192.168.10.51"
ipAddress(5,1)="192.168.10.52"
ipAddress(5,2)="192.168.10.53"
ipAddress(5,3)="192.168.10.54"
'Define program variables
Dim roomStr
Dim compStr
Dim roomNum
Dim compNum
Dim ans
roomStr = ""
compStr=""
roomNum=0
compNum=0
ans = ""
Do
WScript.Echo "Please Enter A Room Number (100-105) ...... "
roomStr = WScript.StdIn.ReadLine
If IsNumeric(roomStr) Then
If (roomStr >= 100) And (roomStr <= 105) Then Exit Do
End If
WScript.Echo Chr(7)
WScript.Echo Chr (7)
WScript.Echo "Error, 100 to 105 Only!!!"
Loop
Do
WScript.Echo "Please Enter The Computer Number (1-4) ......"
compStr = WScript.StdIn.ReadLine
If IsNumeric(compStr) Then
If (compStr >= 1) And (compStr <=4) Then Exit Do
End If
WScript.Echo Chr (7)
WScript.Echo Chr (7)
WScript.Echo "Error, 1 to 4 Only!!!"
Loop
'Display All IP Addresses Y/N?
Do
WScript.StdOut.Write("Do you wish to Display all of the IP Address Y/N......")
Ans = WScript.StdIn.ReadLine()
If UCase(Ans) <> "Y" And UCase(Ans) <> "N" Then
WScript.StdOut.Write Chr (7)
WScript.StdOut.Write Chr (7)
WScript.Echo "Error,Y,y,N,n Responses Only!!!"
End If
Loop While UCase(Ans) <> "N" And UCase(Ans) <> "Y"
If UCase(Ans) = "Y" Then
For RoomNum = 0 To 5
For CompNum = 0 To 3
WScript.Echo "The IP Address in Room " & roomNum+100 & " for computer " & compnum+1 & " is " & ipAddress(roomNum,compNum)
Next
Next
End If
If UCase(Ans) = "N" Then
WScript.Echo " The IP Address In Room " & roomStr & " for computer " & compStr & " is " & IpAddress(roomNum,compNum)
End If