Question

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
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Raw code:

Module Module1
Sub Main() 'declaring the function
'creating an array of given strings
Dim Colors() As String = {"red","blue","green","yellow","purple","orange","marron","cream","violet","teal"}
Dim len As Integer = Colors.Length 'declaring the len variable with lenght of Colors array
For i As Integer = 0 To Colors.Length - 1
'for printing the required output
Console.WriteLine("{0} {1} {2}",UCase(Left(Colors(i Mod len), 1)) & Mid(Colors(i Mod len), 2),
UCase(Left(Colors((i+1) Mod len), 1)) & Mid(Colors((i+1) Mod len), 2),
UCase(Left(Colors((i+2) Mod len), 1)) & Mid(Colors((i+2) Mod len), 2))
'UCase(Left(Colors(i Mod len), 1)) this captlise the fist letter
'mod is for to over the come problem of array goes out of bound
Next
End Sub
End Module

note: please make indentation according to the screen shot of the editor

code screen shot:

out put:

Add a comment
Know the answer?
Add Answer to:
Use VbScript to go through an array of colors. Create a 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 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...

  • 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...

  • 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)....

  • For each of the solutions described below, determine the pH range for the solution using the...

    For each of the solutions described below, determine the pH range for the solution using the information given and the indicator chart Solution A Indicator Used alizarin yellow Indicator color Yellow bromthymol blue yellow methyl violet violet Range bear the 21 less than 7.6 leathen lib really them 5.1 Gooher the 3.2 bromcresol green green methyl red red The pH range for solution A is 3.2 7.6 Solution B Indicator Used methyl red Indicator color yellow Range leroth 67 alizarin...

  • Use the Table 7.1, estimate the pH of following solutions. The colors of the 4 indicators...

    Use the Table 7.1, estimate the pH of following solutions. The colors of the 4 indicators in the solution are given. Explain your answer a. Solution A 2. 3. Make studie acid s you g your pre-l thymol blue: yellow methyl orange: yellow methyl red: orange bromothymol blue: yellow Range of pH b. Solution B thymol blue: yellow methyl orange: yellow methyl red: yellow bromothymol blue: blue Range of pH Row C: methyl red Row D: bromthymol blue 4. Swirl...

  • 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....

  • (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...

  • 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...

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