Compare largest number among a list of XML input parse using Excel VBA
Set node = xmldoc.SelectNodes("//Attribute[@name='XSHIP_LOCATION']")
For Each n In node
result = n.Text
logmsg = "XSHIP_LOCATION: " & result
Call PrintLog(logmsg, logline)
Next n
For every line in xml that contains name=XSHIP_LOCATION, the value of that attribute will be read. How can i compare the list of results read from XML and pick the highest number?
Example of result = 1, 2,1,3,5,4,1,2
I would like to find the largest number 开发者_如何学运维from the list of inputs read from XML which is 5 in this case using .
Can anyone kind enough to help this newbie? Thanks
why not add a second variable to capture the maximum value, then each iteration through the loop, compare the maximum to the result.... as such
result = n.Text '->your code
if result > max then max = result
logmsg = "XSHIP_LOCATION: " & result '--> your code
Note that if n is NOT a number, this will throw an error.
精彩评论