mc-Things

mc-Products => mc-Module => Topic started by: Nick_W on January 26, 2017, 03:03:52 pm

Title: Convert String to Integer
Post by: Nick_W on January 26, 2017, 03:03:52 pm
I'm trying to convert a string to an Integer

Page 91 of the guide gives this function for object type String:

Code: [Select]
Public Function ToInteger(Hex As String) as Integer

But I can't get it to work ("Undefined Function"), and I don't know what Hex is supposed to be (some kind of formatting string I assume).

Im using

Code: [Select]
Integer.TryConvert(motionStopTime, stopInt)

Instead. Anyone know the syntax for converting a String to an Integer?

Thanks,
Title: Re: Convert String to Integer
Post by: mc-John on January 31, 2017, 06:38:24 pm
Code: [Select]
        Dim stopInt As Integer = -1
        If Integer.TryConvert("100", stopInt) Then
            //Success Variable stopInt contains 100
        Else
            // Failure stopInt contains -1
        End If

It does not handle hex values like "0x64" though