Está en la página 1de 4

Student Name Cole Morris Class COMP230 Date 20170604

VBScript IP Array Report


In the space provided below, copy and paste your IP_Array.vbs Program Code. If it doesnt fit,
use the next page for the continuation of your sourcecode program.
' VBScript: IP_Array.vbs
' Written by: COLE MORRIS
' Date: 20170604
' Class: COMP230
' Professor: McKenzie
' ===================================
' 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 Script Variable


roomStr=""
compStr=""
room=0
computer=0

Do
roomStr=InputBox("Please Enter the Room Number (100-105)....")
room = CInt(roomStr)
If room < 100 Or room > 105 Then
WScript.Echo Chr(7) & Chr(7)
MsgBox("Error, 100 to 105 Only!!!")
End If
Loop While room < 100 Or room > 105
COMP230_Wk4_IP_Array_Report.docx 1 Revision Date: 1213
In the space provided below to copy and paste the remainder of your IP_Array.vbs
sourcecode.
Loop While room < 100 Or room > 105

Do
compStr=InputBox("Please Enter the Computer Number (1-4)....")
computer = CInt(compStr)
If computer < 1 Or computer > 4 Then
WScript.Echo Chr(7) & Chr(7)
MsgBox("Error, 1 to 4 Only!!!")
End If
Loop While computer < 1 Or computer > 4

WScript.Echo "The IP Address in Room " & room & " for computer " & computer & " is " &
ipAddress(room-100,computer-1)

'Display All IP Address Y/N?


Do
ans=InputBox("Do you wish to Display all of the IP Address (Y/N)....")
If ans <> "Y" And ans <> "y" And ans <> "N" And ans <> "n" Then
WScript.Echo Chr(7) & Chr(7)
MsgBox("Error, Y ,y,N,n response Only!!!")
WScript.Echo
End If
Loop While ans <> "Y" And ans <> "y" And ans <> "N" And ans <> "n"

If ans = "Y" Or ans = "y" Then


WScript.Echo
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

COMP230_Wk4_IP_Array_Report.docx 2 Revision Date: 1213


In the space provided below, copy and paste the RUN of your IP_Array.vbs program.
C:\comp230>IP_Array.vbs

C:\comp230>cscript IP_Array.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

The IP Address in Room 101 for computer 1 is 192.168.10.19

The IP Address in Room 100 for computer 1 is 192.168.10.11


The IP Address in Room 100 for computer 2 is 192.168.10.12
The IP Address in Room 100 for computer 3 is 192.168.10.13
The IP Address in Room 100 for computer 4 is 192.168.10.14
The IP Address in Room 101 for computer 1 is 192.168.10.19
The IP Address in Room 101 for computer 2 is 192.168.10.20
The IP Address in Room 101 for computer 3 is 192.168.10.21
The IP Address in Room 101 for computer 4 is 192.168.10.22
The IP Address in Room 102 for computer 1 is 192.168.10.27
The IP Address in Room 102 for computer 2 is 192.168.10.28
The IP Address in Room 102 for computer 3 is 192.168.10.29
The IP Address in Room 102 for computer 4 is 192.168.10.30
The IP Address in Room 103 for computer 1 is 192.168.10.35
The IP Address in Room 103 for computer 2 is 192.168.10.36
The IP Address in Room 103 for computer 3 is 192.168.10.37
The IP Address in Room 103 for computer 4 is 192.168.10.38
The IP Address in Room 104 for computer 1 is 192.168.10.43
The IP Address in Room 104 for computer 2 is 192.168.10.44
The IP Address in Room 104 for computer 3 is 192.168.10.45
The IP Address in Room 104 for computer 4 is 192.168.10.46
The IP Address in Room 105 for computer 1 is 192.168.10.51
The IP Address in Room 105 for computer 2 is 192.168.10.52
The IP Address in Room 105 for computer 3 is 192.168.10.53
The IP Address in Room 105 for computer 4 is 192.168.10.54

COMP230_Wk4_IP_Array_Report.docx 3 Revision Date: 1213


COMP230_Wk4_IP_Array_Report.docx 4 Revision Date: 1213

También podría gustarte