canberrasnag
Programmer
I am having a problem with two nested FOR EACH loops.
it seems as though the inside for each loop, once complete, at the second attempt into the loop, it goes straight to the exit of the loop as though it has already finished... why????
don't the variables reset?
how can I do this?
the code follows.
the code opens a form in a page, goes through each text field in the form and inserts a character.
if the field name is the same as the name in the outside loop, then it inserts a special character.
I can't get past the first loop..
Code:
' ***********************************************************************************
' * File Name:
' *
' * Author :
' *
' * Company :
' *
' * Date :
' *
' * History :
' *
' ***********************************************************************************
' *********Variable Initialisations blow this line***********************************
Dim IEObject, allowableCharacters(), fileObject, charactersFile
'create the IE application object
Set IEObject = CreateObject("InternetExplorer.Application")
Set fileObject = CreateObject("Scripting.FileSystemObject")
Set charactersFile = fileObject.OpenTextFile("allowedTextFieldCharacters.txt",1)
' *********Main Application Processing goes below this line**************************
iUpperBound = 0
While Not charactersFile.AtEndOfStream
ReDim Preserve allowableCharacters(iUpperBound)
allowableCharacters(iUpperBound) = charactersFile.Read(1)
iUpperBound = iUpperBound + 1
Wend
IEObject.Visible=true
IEObject.Navigate2("
do until IEObject.readyState = 4
loop
Dim insideFormer
For Each former In IEObject.Document.Forms
For Each inputObj In former
MsgBox(inputObj.name)
'MsgBox(inputObj.type)
If inputObj.Type = "text" Then
For Each otherInputObj In insideFormer
'MsgBox(otherInputObj.name)
'MsgBox(otherInputObj.type)
If otherInputObj.Type = "text" Then
'MsgBox(otherInputObj.name)
'MsgBox("Outside : " &inputObj.name & "Inside : " &otherInputObj.name)
If inputObj.name = otherInputObj.name Then
otherInputObj.value = "û"
Else
otherInputObj.value = "A"
End If
End If
Next
MsgBox("Click Submit")
For i = 1 To 50000
Next
IEObject.Visible=true
IEObject.Navigate2("
do until IEObject.readyState = 4
loop
End If
MsgBox("Outside : " &inputObj.name )
Next
Next
it seems as though the inside for each loop, once complete, at the second attempt into the loop, it goes straight to the exit of the loop as though it has already finished... why????
don't the variables reset?
how can I do this?
the code follows.
the code opens a form in a page, goes through each text field in the form and inserts a character.
if the field name is the same as the name in the outside loop, then it inserts a special character.
I can't get past the first loop..
Code:
' ***********************************************************************************
' * File Name:
' *
' * Author :
' *
' * Company :
' *
' * Date :
' *
' * History :
' *
' ***********************************************************************************
' *********Variable Initialisations blow this line***********************************
Dim IEObject, allowableCharacters(), fileObject, charactersFile
'create the IE application object
Set IEObject = CreateObject("InternetExplorer.Application")
Set fileObject = CreateObject("Scripting.FileSystemObject")
Set charactersFile = fileObject.OpenTextFile("allowedTextFieldCharacters.txt",1)
' *********Main Application Processing goes below this line**************************
iUpperBound = 0
While Not charactersFile.AtEndOfStream
ReDim Preserve allowableCharacters(iUpperBound)
allowableCharacters(iUpperBound) = charactersFile.Read(1)
iUpperBound = iUpperBound + 1
Wend
IEObject.Visible=true
IEObject.Navigate2("
do until IEObject.readyState = 4
loop
Dim insideFormer
For Each former In IEObject.Document.Forms
For Each inputObj In former
MsgBox(inputObj.name)
'MsgBox(inputObj.type)
If inputObj.Type = "text" Then
For Each otherInputObj In insideFormer
'MsgBox(otherInputObj.name)
'MsgBox(otherInputObj.type)
If otherInputObj.Type = "text" Then
'MsgBox(otherInputObj.name)
'MsgBox("Outside : " &inputObj.name & "Inside : " &otherInputObj.name)
If inputObj.name = otherInputObj.name Then
otherInputObj.value = "û"
Else
otherInputObj.value = "A"
End If
End If
Next
MsgBox("Click Submit")
For i = 1 To 50000
Next
IEObject.Visible=true
IEObject.Navigate2("
do until IEObject.readyState = 4
loop
End If
MsgBox("Outside : " &inputObj.name )
Next
Next