is Recursive Procedures/Function what i need to solve my problem?

G

Guest

this is my code


Do
Dim nn As String

Dim strNetControl As String = CStr(arlsNetControl.Item(y))
rootDoc.Load(strNetControl)
lsSubNetInst =
rootDoc.SelectNodes("/NetworkController/Subnets/Subnet/SubnetProperties/@NetworkNumber")
str1 = strNetControl.Substring(0, strNetControl.LastIndexOf("."))

For Each nSubNetInst In lsSubNetInst
arlsSubNetInst.Add(nSubNetInst.InnerText)
Next
nn = CStr(arlsSubNetInst.Item(y))

Dim intR As Integer = NxInstNum + 2

strSubNet = str1 + "_" + "200" + "." + nn + "_" + "199" + "." +
CStr(intR) + ".xml"
cboJobSite.Items.Add(strSubNet)

y += 1
Loop Until y = x

what i need is for CStr(intR) to increase by two each time when i loop it
thur. it suppose to loop 12 time and each time the build up on the file alway
end up with same number which is 3752. the variable NxInstNum is 3750.

since it must loop thur 12 time each time the build up file should be

C:\eBuilding\config\client\Data\Site_7415\800.7415_801.101_8.115_200.391_199.3752.xml

then

C:\eBuilding\config\client\Data\Site_7415\800.7415_801.101_8.115_200.391_199.3754.xml

and so on...

does anyone know what i'm doing wrong or missing?

thanks
 
P

Patrice

Dim intR As Integer = NxInstNum + 2 and as NxInstNum never change you alway
suse the same value.

Move Dim intR As Integer = NxInstNum outisde of your llop and use
intR=intR+2 inside your loop.
 
S

Shane

There is no need for recursion.
I assume that x and y are set outside of this code snippet.

The problem is your positioning of
Dim intR As Integer = NxInstNum + 2
Since NxInstNum = 3750, and that variable is never changed, your result
will always be 3752.

Actually, I'm surprised that you aren't getting errors out the
ying/yang with this code. The same variables are dimensioned in every
iteration of the loop. Older versions of VB would have cried about
that.

Try this instead:

Dim nn As String = ""
Dim strNetControl As String = ""
Dim intR As Integer = NxInstNum
Do
strNetControl = CStr(arlsNetControl.Item(y))
rootDoc.Load(strNetControl)
lsSubNetInst =

rootDoc.SelectNodes("/NetworkController/Subnets/Subnet/SubnetProperties/@NetworkNumber")
str1 = strNetControl.Substring(0, strNetControl.LastIndexOf("."))
For Each nSubNetInst In lsSubNetInst
arlsSubNetInst.Add(nSubNetInst.InnerText)
Next
nn = CStr(arlsSubNetInst.Item(y))
intR += 2
strSubNet = str1 + "_" + "200" + "." + nn + "_" + "199" + "." +
CStr(intR) + ".xml"
cboJobSite.Items.Add(strSubNet)
y += 1
Loop Until y = x
 
G

Guest

Thank you, i got my mind wrap around on this program that i miss the most
simple element of it.
 
Top