Comparing Two Variables (return max)

Assistance please. I am trying to compare two variables scraped from a general website e.g. 100% = var1 and 90% = var2, and return the larger variable as a new variable = var. Plan is the larger variable will then trigger what additional data I scrape from general website.

Not a vb expert, but imagine there is a simple Write Line I can do to achieve my intended purpose.

First convert the strings to numerical values. In this case you’d use 100 and 90 or 1 and 0.9.

Then, in an Assign block do
max = Math.Max(var1,var2)

This will set the variable max to whichever variable is larger, var1 or var2.

Thank you Daniel. Do you potential know how to also convert to the integer? I have tried to store the 100% and 90% as String as well as GenericValue variable and then used an assign block to attempt to “convert.ToInt32(var1)” as well as “cint(var1)” but no combination of these work. I receive the following error message. Compiler error(s) encountered processing expression (those above). Option Strict On disallows implicit conversions from Integer to String."

First you need to trim the “%” off of the end.

number = number.Substring(0,number.Length-1)
(now your variable is “100” instead of “100%”)

someInteger = Integer.Parse(number)
(someInteger is an integer variable equal to 100)

Do this for both values then you can use Max with the integer values.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.