Hi,

I haven't done a lot of data type converting so please bear with me. I'm grabbing data from a field that's formatted for currency (2 decimal places) and assigning it a variable. I then run an if statement against it, but I'm getting a conversion error. Here is my code:

Dim CapAmount as String 

    If CapAmount >= 3000 Then
        'Do stuff
    End If

When I type 3000.00 into the editor it removes the last 0 and changes it to a double.If I remove the (.) it changes it to an integer. So should I be casting to a double or decimal to get the right type? I'm doing this in Infopath's code editor if that makes a difference. Any help is appreciated! Thanks.

Here is the error message:
Conversion from string "" to type 'Integer' is not valid.at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)

Recommended Answers

All 2 Replies

You have to convert the string to a number first. In your case that would be

If CDec(CapAmount) >= 3000 Then
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.