0% found this document useful (0 votes)
257 views3 pages

Comp230 Wk4 Ip Array 1

The document contains the source code for a VBScript program that initializes a 2-dimensional array to store IP addresses. The array indexes the IP addresses by room number and computer number within each room. The program prompts the user to enter a room and computer number, then displays the corresponding IP address. It also allows displaying all IP addresses stored in the array. When run, the program demonstrates retrieving a single IP address from the array and displaying all IP addresses.

Uploaded by

Portia Lanier
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
257 views3 pages

Comp230 Wk4 Ip Array 1

The document contains the source code for a VBScript program that initializes a 2-dimensional array to store IP addresses. The array indexes the IP addresses by room number and computer number within each room. The program prompts the user to enter a room and computer number, then displays the corresponding IP address. It also allows displaying all IP addresses stored in the array. When run, the program demonstrates retrieving a single IP address from the array and displaying all IP addresses.

Uploaded by

Portia Lanier
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

COMP230_Wk4_IP_Array_Report.

docx Revision Date: 1213


1
Student Name Class Comp 230 Date
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: Student Name
' Date: Today's Date
' Class: COMP230
' Professor: Professor Name
' ===================================
' 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=""
ansStr=""
room=0
computer=0
ans=0
DO
WScript.StdOut.Write("Please Enter the Room Number (100-105) .....")
roomStr = WScript.StdIn.Readline()
room = CInt(roomStr)
If room < 100 OR room > 105 Then
WScript.StdOut.WriteLine(chr(7) & chr(7) & "Error, 100 to 105 Only!!!")
WScript.echo
End If
Loop While room < 100 OR room > 105
Do
WScript.StdOut.Write("Please Enter the Computer Number (1-4) ...... ")
compStr = WScript.StdIn.ReadLine()
COMP230_Wk4_IP_Array_Report.docx Revision Date: 1213
2
In the space provided below to copy and paste the remainder of your IP_Array.vbs
sourcecode.

WScript.echo
End If
Loop While room < 100 OR room > 105
Do
WScript.StdOut.Write("Please Enter the Computer Number (1-4) ...... ")
compStr = WScript.StdIn.ReadLine()
computer = CInt(compStr)
If computer < 1 OR computer > 4 Then
WScript.StdOut.WriteLine(chr(7) & chr(7) & " Error, 1 to 4 Only!!!")
WScript.Echo
End If
Loop While computer < 1 OR computer >4
WScript.StdOut.WriteLine (vbCrLf & "The IP Address in Room " & room & "for computer " &
computer & "is" & ipAddress(room-100,computer-1))
WScript.Echo
'Display All Ip addresses Y/N?
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 reponse 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 room = 0 to 5
for computer = 0 to 3
WScript.StdOut.WriteLine (vbCrLf & "The IP Address in Room " & room+100 & " for
Computer " & computer+1 & "is" & ipAddress(room,computer))
Next
Next
End IF

COMP230_Wk4_IP_Array_Report.docx Revision Date: 1213
3

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

Please Enter the Room Number (100-105) .....101
Please Enter the Computer Number (1-4) ...... 5
Error, 1 to 4 Only!!!

Please Enter the Computer Number (1-4) ...... 2

The IP Address in Room 101for computer 2is192.168.10.20

Do you wish to Display all of the IP Addresses (Y/N) ....y


The IP Address in Room 100 for Computer 1is192.168.10.11

The IP Address in Room 100 for Computer 2is192.168.10.12

The IP Address in Room 100 for Computer 3is192.168.10.13

The IP Address in Room 100 for Computer 4is192.168.10.14

The IP Address in Room 101 for Computer 1is192.168.10.19

The IP Address in Room 101 for Computer 2is192.168.10.20

The IP Address in Room 101 for Computer 3is192.168.10.21

The IP Address in Room 101 for Computer 4is192.168.10.22

The IP Address in Room 102 for Computer 1is192.168.10.27

The IP Address in Room 102 for Computer 2is192.168.10.28

The IP Address in Room 102 for Computer 3is192.168.10.29

The IP Address in Room 102 for Computer 4is192.168.10.30

The IP Address in Room 103 for Computer 1is192.168.10.35

The IP Address in Room 103 for Computer 2is192.168.10.36

The IP Address in Room 103 for Computer 3is192.168.10.37

The IP Address in Room 103 for Computer 4is192.168.10.38

The IP Address in Room 104 for Computer 1is192.168.10.43

The IP Address in Room 104 for Computer 2is192.168.10.44

The IP Address in Room 104 for Computer 3is192.168.10.45

The IP Address in Room 104 for Computer 4is192.168.10.46

You might also like