Hi,
I encountered an error in this expression with the following error message: “If: Input string was not in a correct format” for this expression :
CountryOutput.Equals(Country_Iteration) = True And Int32.Parse(Supplier_ID_Iteration) = Int32.Parse(SupplierID_Iteration_BL)
for information: the value of “SupplierID_Iteration_BL” is “9999” it is fixed but the value of “Supplier_ID_Iteration” normally a string which contains a number (digits) for the case where I received an error the “Supplier_ID_Iteration” contains an empty string and once string which contains a character string.
how can solve this issue ?
as per error and info provided looks like SupplierID_Iteration_BL is having some data which are not digits…if so we cannot parse it as integer.please check the same
and condition can be like this
CountryOutput.Equals(Country_Iteration) And Cint(Supplier_ID_Iteration).Equals(Cint(SupplierID_Iteration_BL))
and in the case that “Supplier_ID_Iteration” is a string “ACM_49007949” and i got this error message :
If: Conversion from string “ACM_49007949” to type ‘Integer’ is not valid.
Assign isValidSupplierIDIteration = Int32.TryParse(Supplier_ID_Iteration, supplierIDIteration)
Assign isValidSupplierIDIterationBL = Int32.TryParse(SupplierID_Iteration_BL, supplierIDIterationBL)
If CountryOutput.Equals(Country_Iteration) AndAlso isValidSupplierIDIteration AndAlso isValidSupplierIDIterationBL AndAlso supplierIDIteration = supplierIDIterationBL Then
' Your code for when the conditions are met
Else
' Your code for when the conditions are not met
End If
Hi @aya_lajili1
The error message you’re encountering, “Input string was not in a correct format,” typically occurs when you’re trying to parse a string into an integer, but the string does not contain a valid integer representation. In your case, you are trying to parse the Supplier_ID_Iteration string, which may sometimes be empty or contain non-numeric characters.
You can modify your expression to handle this:
CountryOutput.Equals(Country_Iteration) = True And
If(String.IsNullOrWhiteSpace(Supplier_ID_Iteration), False,
Int32.TryParse(Supplier_ID_Iteration, Nothing)) = True And
Int32.TryParse(SupplierID_Iteration_BL, Nothing) = True
how to put all that on one expression
CountryOutput.Equals(Country_Iteration) = True And
If(String.IsNullOrWhiteSpace(Supplier_ID_Iteration), False,
Int32.TryParse(Supplier_ID_Iteration, Nothing)) = True And
Int32.TryParse(SupplierID_Iteration_BL, Nothing) = True
CountryOutput.Equals(Country_Iteration) = True And Int32.TryParse(Supplier_ID_Iteration, Supplier_ID_Parsed) And Int32.TryParse(SupplierID_Iteration_BL, SupplierID_Parsed_BL) And Supplier_ID_Parsed = SupplierID_Parsed_BL
it work’s , just i have a quetion because i want to make a check on this variable Supplier_ID_Iteration if it is a number means contain only digits or contain string to exclude from the beginig