Convert 1 line of code to new framework?

Hi,
I am having trouble updating my code to the new framework.

Could someone please tell me how I convert my code below (RGBArray is a string):

Dim R As Integer = Val(RGBArray(0)) / 255 * 100

I tried the code below - but it was not correct, so now I am stumped :frowning:

Dim R As Integer = RGBArray(0).ToInteger / 255 * 100

Do I have to separate this into 2 lines of code - as below:

Dim R As Integer = RGBArray(0).ToInteger R = R / 255 * 100

Thank you in advance.

Use Integer.Parse(aText). There is no Text.ToInteger.

That’ll probably be why then :slight_smile:

Thanks.

Really struggling with this - my syntax below is also wrong??

Dim R As Integer = Integer.Parse(RGBArray(0)) / 255 * 100

What’s wrong? You are effectively dividing the value of RGBArray(0) by 25500 due to precedence. You probably want to use brackets

(Integer.Parse(RGBArray(0)) / 255) * 100

to get the result you’re looking for.

Wayne - how do I include the Dim statement in your example??

I need to convert this - to your example:

Dim R As Integer = Val(RGBArray(0)) / 255 * 100

If you want to use the new framework, then likely you should be working with an array of Text (new framework)- not of String (classic framework).

Ah - I guess that’s the problem then. I will try changing that also.
Thanks.

Dim R As Integer = (Val(RGBArray(0)) / 255) * 100