none
IP Array Script RRS feed

  • Question

  • This is a lab i'm working on and for some odd reason I keep getting Ip_Array.vbs(43, 23) Microsoft VBScript compilation error: Expected ')' but on multiple lines. I can't figure out whats happening here. where the problem is is in the first "while" and in the parentheses in that line. 

    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 Script Variables
    roomStr=""
    compStr=""
    room=0
    computer=0
    Read number
    While number <= 0  (a negative number is invalid data)
        Print error message, ask user to re-enter
        Read number
     End While

    Display Prompt "Please Enter the Room Number (100-105) ...... "
    Get StdIn Console Input and assign string value to roomStr

    room = CInt(roomStr)
    While room < 100 OR room > 105
            Use StdOut to Beep Speaker twice with chr(7)
            Display ErrMsg "Error, 100 to 105 Only!!!"
            Display Prompt "Please Enter the Room Number (100-105) ...... "
            Get StdIn Console Input and assign string value to roomStr
            room = CInt(roomStr)
    End While

    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:21 PM This is not "fix/debug/rewrite script for me" forum
    Monday, March 25, 2019 1:39 PM

All replies

  • You should not be using VBScript.  It is obsolete.  DO not waste your time trying to learn it.

    Most of your code is not correct syntax. 

    Please edit your script and post it correctly using the code posting tool provided on the edit bar.

    With any code start by fixing the first error reported.  Always fix all syntax errors first.


    \_(ツ)_/

    Monday, March 25, 2019 2:34 PM
  • This is what I have now but I cant get the script to run I get Microsoft VBScript compilation error: Expected 'Wend' This is at the very end of where the end if is

    ' This initializes 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 Script Variables
    roomStr=""
    compStr=""
    room=0
    computer=0


    Do
      WScript.echo "Please Enter the 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 Address Y/N?
      Do
       WScript.StdOut.Write ("Do you wish to Display all of the IP Address (Y/N)....")
      ans = WScript.StdIn.ReadLine()
      if ans = "N" or ans = "n" then
        WScript.StdOut.Write Chr(7)
        WScript.StdOut.Write Chr(7)
        WScript.StdErr.Write "Error,Y,y,N,n Response Only!!!"
      End if

    While ans = "N" or ans = "n"

    If ans = "Y" or ans = "y" then
     For room = 0 to 5
     Next
      For computer = 0 to 3
      Next
       WScript.Echo "The IP Address in Room" + room+ 100
      'WScript.Echo "for Computer" (computer+1)
       'WScript.Echo "is" + IPAddress(Room, computer)
      End if

              
    Monday, March 25, 2019 5:09 PM
  • Please only use code posting tool provided on the edit bar.  Please edit your original post and post the code correctly. 

    You must post the first error in full as a minimum. We cannot help if you do not provide correct, accurate and readable information.

    You must also post the complete error message which also contains line number and other information.  YOu have many syntax errors in your script.

    I remind you that VBScript is obsolete.  DO not waste your time trying to learn it.


    \_(ツ)_/


    • Edited by jrv Monday, March 25, 2019 5:19 PM
    Monday, March 25, 2019 5:17 PM