I have two For loop, first For loop does is creates a customer and input the customer info and then the second for loop within the first for loop does the follows which is capture the customer name and verify the with the data within the datatable. The problem I am coming across is that when it goes through the second time creating another customer and then verify the second customer then it creates the following during runtime. I want is to have the customer2 below Customer1 under the Customer_from_Apps. Any help will be greatly appreciate it.

Customer Customer_from_Apps Customer_from_Apps1
Customer1 Customer 1 Customer2
Customer2

Window("Customer Desktop").Window("Customer Tracking (Privacy").WinObject("TreeView20WndClass").Click 92,244
runtimevalue = .VbTreeView("vbname:=AppServerTree").GetROProperty("Selection")
Customer_Val= Datatable.GlobalSheet.AddParameter ("Customer_from_Apps",runtimevalue)
row=datatable.getsheet("Global").GetRowCount
For x=1 to row
datatable.SetCurrentRow(x)

Data_Val=Datatable.Value("Customer",dtGlobalSheet)
If (trim(Customer_Val)=trim(Data_Val)) Then
Reporter.ReportEvent micPass, "Customer validation successful", "Actual Value: " &Data_Val&vbcrlf& "Customer Value: " &Customer_Val
else
Reporter.ReportEvent micFail, "Cusotmer validation unsuccessful", "Actual Value: " &Data_Val&vbcrlf& "Customer Value: " &Customer_Val
End If
Next

it would help if you formated your text but I can only see one loop in code

Temp_Value = DataTable.GlobalSheet.AddParameter("Customer_from_Apps", "")
	For i = 1 to 2
	datatable.SetCurrentRow(i)
	.VbTreeView("vbname:=AppServerTree").GetROProperty ("all items") 

	'Search
	.VbTreeView("vbname:=AppServerTree").Select "Desktop;Search" 
	.VbWindow("vbname:=frmCustomerSearch").VbButton("vbname:=cmdNewCustomer").Click
With.VbWindow("vbname:=frmCustomerSearch").VbWindow("vbname:=frmCustomer")

'Patient Tab
.VbEdit("vbname:=txtLastName").Set DataTable("Last", dtLocalSheet)
.VbEdit("vbname:=txtFirstName").Set DataTable("First", dtLocalSheet)

VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").ActiveX(":-) VideoSoft IndexTab").ActiveX("Threed Panel Control").ActiveX("MaskEdBox_3").Type Datatable("DOB",dtLocalSheet)
.VbComboBox("vbname:=cboRace").Select DataTable("Race", dtLocalSheet)
.VbComboBox("vbname:=cboGender").Select DataTable("Gender", dtLocalSheet)

ssnRowNum = 1
maxRows = 100
SSN=888416381
For x = 1 to maxRows
datatable.SetCurrentRow(ssnRowNum)
				  VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").ActiveX(":-) VideoSoft IndexTab").ActiveX("Thread Panel Control").ActiveX("MaskEdBox").Type SSN
.VbButton("vbname:=cmdApply").Click
If VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").Dialog("Customer Desktop").Exist Then 

VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").Dialog("Customer Desktop").WinButton("OK").Click
SSN = SSN + 1
Else
Exit For
End if
Next

validSSN = VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").ActiveX(":-) VideoSoft IndexTab").ActiveX("Threed Panel Control").ActiveX("MaskEdBox").GetROProperty("Text")
LastName = .VbEdit("vbname:=txtLastName").GetROProperty("Text")
FirstName = .VbEdit("vbname:=txtFirstName").GetROProperty("Text")
DOB = VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbWindow("frmCusotmer").ActiveX(":-) VideoSoft IndexTab").ActiveX("Threed Panel Control").ActiveX("MaskEdBox_3").GetROProperty("Text")
Reporter.ReportEvent micPass, "Customer", "  " & "      " &FirstName&  "     " &LastName&vbcrlf& "   " & validSSN&vbcrlf& "     "  &DOB

'Address
Set Keyboard = DotNetFactory.CreateInstance( "Microsoft.VisualBasic.Devices.Keyboard", "Microsoft.VisualBasic" )
Call Keyboard.SendKeys( "%+r", True )
.VbButton("vbname:=cmdNew").Click
.VbComboBox("vbname:=cboAddressType").Select DataTable("Address_Type", dtLocalSheet)
.VbEdit("vbname:=txtStreet").Set DataTable("Street", dtLocalSheet)
.VbEdit("vbname:=txtStreet2").Set DataTable("Street_2", dtLocalSheet)
.VbEdit("vbname:=txtCity").Set DataTable("City", dtLocalSheet)
.VbEdit("vbname:=txtState").Set DataTable("State", dtLocalSheet)
.VbEdit("vbname:=txtZipCode").Set DataTable("Zip_Code", dtLocalSheet)
.VbButton("vbname:=cmdApply").Click
wait 2

'Phone
Set Keyboard = DotNetFactory.CreateInstance( "Microsoft.VisualBasic.Devices.Keyboard", "Microsoft.VisualBasic" )
Call Keyboard.SendKeys( "%+h", True )
.VbButton("vbname:=cmdNew").Click
.VbComboBox("vbname:=cboPhoneNumbers").Select DataTable("Phone_Type", dtLocalSheet)
.VbEdit("vbname:=txtAreaCode").Set DataTable("Area_Code", dtLocalSheet)
.ActiveX("text:=   -   ").Type DataTable("Number", dtLocalSheet)
.VbEdit("vbname:=txtExtension").Set DataTable("Extension", dtLocalSheet)
.VbButton("vbname:=cmdApply").Click
wait 2	
VbWindow("CWMainForm").VbWindow("frmCusotmerSearch").VbButton("OK").Click
End With

Window("Customer Desktop").Window("Customer Tracking").WinObject("TreeView20WndClass").Click 92,244
runtimevalue =  .VbTreeView("vbname:=AppServerTree").GetROProperty("Selection")
row=datatable.getsheet("Global").GetRowCount 
For x=1 to row
datatable.SetCurrentRow(x)
datatable.Value("Customer_in_Apps", dtGlobalSheet) = runtimevalue
 Data_Val=Datatable.Value("Customer",dtGlobalSheet) 
	
If (trim(runtimevalue)=trim(Data_Val)) Then
Reporter.ReportEvent micPass, "Customer validation successful", "Actual Value:   " &Data_Val&vbcrlf&  "Apps  Value:  " &runtimevalue
							else
Reporter.ReportEvent micFail, "Customer validation unsuccessful", "Actual Value:  " &Data_Val&vbcrlf&  "Apps Value:  " &runtimevalue
End If	

Next

Next

End With

Edited 4 Years Ago by WaltP: Ad

I know the MEMBER RULES you read mentioned CODE Tags. USE THEM!

And when someone asks you for format your code, format your code!

I tried to format what you had. But it was an exercise in aggravation.

Here's one thing to avoid doing:

Don't Use a With, End With statement in the middle of a series of For Next Statements. It may work: but it's murder trying to decipher.

Don't forget to use indentation in your code. And don't hesitate to use comments and white space to separate code processes. It may not be necessary, but it certainly helps readability and will not slow down the execution of your program.

For i = 1 to 10
     ' Code
     ' More Code
Next i

With MyForm.Control
     .Open
     .Close
End With

For i = 1 to 10
     ' Code
     ' More Code
     With MyForm.Control
          .Open
          .Close
     End With
    ' Keep your With/ End With inside your For Loop. It looks better and is easier to follos.
Next i
This article has been dead for over six months. Start a new discussion instead.