Question

Use VBScript to go through an array of colors. Create any loop to get the next...

Use VBScript to go through an array of colors.

Create any loop to get the next 2 elements of an array in vbscript.

The array is Colors = Array("red", "blue", "green", "yellow", "purple", "orange", "maroon", "cream", "violet", "teal")

For each element in the array, get the next 2 elements.

Output should be:
red blue green
blue green yellow
green yellow purple
yellow purple orange
purple orange maroon
orange maroon cream
maroon cream violet
cream violet teal
violet teal red
teal red blue

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM


<html>
<body>
<script language = "vbscript" type = "text/vbscript">
   ' initialize the variables
Dim c : c=0
       Dim i : i=0
       Dim Colors
       ' Array named by Colors
Colors = Array("red", "blue", "green", "yellow", "purple", "orange", "maroon", "cream", "violet", "teal")
'Take the length of the array
       l=uBound(Colors) + 1
While(i<l)  
'print color with space          
document.write(Colors(i)& "&nbsp")
i=i+1
c=c+1
       If(c=3) Then
       'back to two colors and print from there
       i=i-2
           c=0
           ' line break
           document.write("<br>")
       End If
       If(i=l) Then
       ' if it reaches to last color
       i=0
       document.write(Colors(i)& "<br>")
           document.write(Colors(l-1)& "&nbsp" & Colors(0)& "&nbsp" & Colors(1) )
           i=l
       End If
   Wend      

         

</script>
</body>
</html>

SCREEN SHOT

OUTPUT

Add a comment
Know the answer?
Add Answer to:
Use VBScript to go through an array of colors. Create any loop to get the next...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use VbScript to go through an array of colors. Create a loop to get the next...

    Use VbScript to go through an array of colors. Create a loop to get the next 2 elements of an array in vbscript. The array is Colors = Array("red", "blue, "green", "yellow", "purple", "orange", "marroon", "cream", "violet", "teal") Output should be: Red Blue green Blue Green Yellow Purple Orange Marroon Cream Violet Teal Violet Teal Red Teal Red Blue For each element in the array, get the next 2 elements

  • Python problem: 1. The colors red, blue, and yellow are known as the primary colors because...

    Python problem: 1. The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here: When you mix red and blue, you get purple. When you mix red and yellow, you get orange. When you mix blue and yellow, you get green. Create a text file with the names of two colors in it. Write a program...

  • Using C++ COLOR MIXER- The color red, yellow, and blue are primary colors because they cannot...

    Using C++ COLOR MIXER- The color red, yellow, and blue are primary colors because they cannot be made by mixing other colors. When you mix 2 primary colors you get the following: When you mix red and blue, you get purple. When you mix red and yellow, you get orange. When you mix blue and yellow, you get green. Write a program to ask the user for 2 primary colors (an error if they are not primary). Then display the...

  • (2) Recall the following fact: In any planar graph, there exists a vertex whose degree is s 5 Use...

    (2) Recall the following fact: In any planar graph, there exists a vertex whose degree is s 5 Use this fact to prove the six-color theorem: for any planar graph there exists a coloring with six colors, i.e. an assignment of six given colors (e.g. red, orange, yellow, green, blue, purple) to the vertices such that any two vertices connected by an edge have different colors. (Hint: use induction, and in the inductive step remove some verter and all edges...

  • In Java: Create an array of Integers with 10 elements, loop (use a for loop) through...

    In Java: Create an array of Integers with 10 elements, loop (use a for loop) through the array of integers printing their values to the screen. Create an array of Strings with 10 elements, loop (use a for loop) through the array of Strings printing their values to the screen. Finally, create an ArrayList of Integers. Use the loop from part 1 above and add each integer as you print it to the ArrayList as well, then start a final...

  • This lab explores the difference between the string type and the enum type. The attached header...

    This lab explores the difference between the string type and the enum type. The attached header file defines an enumeration type, Color, representing different colors. Create vector of Color variables (see Lab 13 to review vectors). Use a loop to ask the user to enter the names of colors.    For each color entered, add the corresponding Color enumeration value to the vector. Ignore any invalid color that is entered (that is, a color that doesn't exist in the enumeration)....

  • 1. What is the correct way to write a JavaScript array? var colors = (1:"red", 2:"green",...

    1. What is the correct way to write a JavaScript array? var colors = (1:"red", 2:"green", 3:"blue") var colors = ["red", "green", "blue"] var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue") var colors = "red", "green", "blue" 2. Which event occurs when the user clicks on an HTML element? onclick onmouseover onchange onmouseclick 3. How do you declare a JavaScript variable? v carName; var carName; variable carName; 4. Javascript is A client-side scripting language that is...

  • A Gumball machine has a number of different colors available: There are a random number of...

    A Gumball machine has a number of different colors available: There are a random number of yellow, blue, white, green, black, purple, silver, cyan and magenta gumballs and one red gumball. With a pocket full of quarters, you have set your heart on getting that single red gumball. So, write a program that will simulate buying gumballs until you get the red one. (Using Python) To start with, the number of gumballs for each color are randomly chosen as follows....

  • 13) The value of the resistance R1 of colors (Red, Black, Black, and Gold) is: Red...

    13) The value of the resistance R1 of colors (Red, Black, Black, and Gold) is: Red Black Gold Gold: 5% Silver 1023 (A) (2052) 22 (B) (20:1) (C) (200+ 10) 2 (D) (2007 20) 2 (E) (27 0.1) Black: 0 Brown: 1 Red: 2 Orange : 3 Yellow : 4 Green: 5 Blue : 6 Violet:7 Gray: 8 White: 9 14) Which of the following equations is correct when applying Kirchhoff loop rule for the circuit shown below (A) 6...

  • Emission line spectra for various elements are shown in Table 1 and Table 2 shows the...

    Emission line spectra for various elements are shown in Table 1 and Table 2 shows the wavelengths for various colors. Remember, E = h*c/?, where E is energy, h = 6.626*10-34 J*s, c = 3.00*108 m/s, ? is the wavelength, and 1 m = 109 nm. Table 1. Emission Line Spectra of Various Elements Element Emission Lines (nm) H 410.2, 434.1, 486.1, 656.3 He 447.1, 492.1, 501.5, 587.5 Hg 404.7, 435.8, 546.1, 577.0 Na 588.9, 589.5 Mg 487.8, 502.5, 574.1,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT