a for eachnext loop is similar to a fornext loop


A For Each...Next loop is similar to a For...Next loop. Rather than repeating the statements a particular number of times, For Each...Next loop repeats group of statements for each item in a collection of objects or for each element of an array. It is especially helpful if you do not know how several elements are present in a collection.

In the given HTML code example, the contents of any Dictionary object are utilized to place text in several text boxes:

HTML

HEAD TITLE Forms and Elements TITLE HEAD

SCRIPT LANGUAGE="VBScript"

 

Sub cmdChange_OnClick

Dim d                   'Create a variable

Set d = CreateObject("Scripting.Dictionary")

d.Add "0", "Athens"    

'Add some keys and items d.Add "1", "Belgrade"

d.Add "2", "Cairo"

a = d.items

For i = 0 To d.Count

document.frmForm.Elements(i).Value = a(i)

Next

End Sub

 

SCRIPT

BODY

CENTER

FORM NAME="frmForm"

Input Type = "Text"

Input Type = "Text"

Input Type = "Text"

Input Type = "Button" NAME="cmd Change" VALUE="Click Here"p

Request for Solution File

Ask an Expert for Answer!!
Visual Basic Programming: a for eachnext loop is similar to a fornext loop
Reference No:- TGS0265911

Expected delivery within 24 Hours