Input string was not in a correct format-Urgent

Hi i encountered this wile debugging the code.
pls help…!!!

Hi @mitul_choudhary

Use the Watch panel (besides Locals) to examine the values of drinvoiceMain.Item(“IGST Amount”) or other variables etc.

Hi @mitul_choudhary

Try CDbl(drInvoiceMain.Item("IGST Amount").ToString) instead of Double.Parse(). Also check if there is any space or any other character other than , and . in the string representation of IGST Amount

this is the string provided in the condition:-
CInt(((Double.Parse(drInvoiceMain.Item(“IGST Amount”).ToString)+Double.Parse(drInvoiceMain.Item(“SGST / UT GST Amount”).ToString)+Double.Parse(drInvoiceMain.Item(“CGST Amount”).ToString))/Double.Parse(drInvoiceMain.Item(“Taxable Value”).ToString))*100)=CInt(drInvoiceMain.Item(“GST Rate”).ToString)

@mitul_choudhary

Try this

CInt(((CDbl(drInvoiceMain.Item("IGST Amount").ToString)+CDbl(drInvoiceMain.Item("SGST / UT GST Amount").ToString)+CDbl(drInvoiceMain.Item("CGST Amount").ToString))/CDbl(drInvoiceMain.Item("Taxable Value").ToString))*100)=CInt(drInvoiceMain.Item("GST Rate").ToString)

Hi @mitul_choudhary, @mitul_choudhary

Does your value contains $ sign or other currency symbols ? The error - input string was not in correct format - seems to indicate that conversion is not successful because the string is not a number

PFA

@kumar.varun2
Pls Help…!!

This is the string :-
CInt(((CDbl(drInvoiceMain.Item(“IGST Amount”).ToString)+CDbl(drInvoiceMain.Item(“SGST / UT GST Amount”).ToString)+CDbl(drInvoiceMain.Item(“CGST Amount”).ToString))/CDbl(drInvoiceMain.Item(“Taxable Value”).ToString))*100)=CInt(drInvoiceMain.Item(“GST Rate”).ToString)

PFA the ouput

Hi @mitul_choudhary

In the Watch Panel, enter

drInvoiceMain.Item(“IGST Amount”)
drInvoiceMain.Item(“SGST / UT GST Amount”)
drInvoiceMain.Item(“CGST Amount”)
drInvoiceMain.Item(“Taxable Value”)
drInvoiceMain.Item(“GST Rate”)

examine the values… should only contain number format

@mitul_choudhary

Try this one

CInt(((CDbl(If(drInvoiceMain.Item("IGST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("IGST Amount").ToString))+CDbl(If(drInvoiceMain.Item("SGST / UT GST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("SGST / UT GST Amount").ToString))+CDbl(If(drInvoiceMain.Item("CGST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("CGST Amount").ToString)))/CDbl(drInvoiceMain.Item("Taxable Value").ToString))*100)=CInt(drInvoiceMain.Item("GST Rate").ToString)

Hi @mitul_choudhary , @kumar.varun2

That is another workaround in case the value is NULL or empty string “”. Setting to zero allows successful conversion to System.Double

PFA

@kumar.varun2 Pls help…!!

CInt(((CDbl(If(drInvoiceMain.Item("IGST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("IGST Amount").ToString))+CDbl(If(drInvoiceMain.Item("SGST / UT GST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("SGST / UT GST Amount").ToString))+CDbl(If(drInvoiceMain.Item("CGST Amount").ToString.Equals(""), "0", drInvoiceMain.Item("CGST Amount").ToString)))/CDbl(drInvoiceMain.Item("Taxable Value").ToString))*100)=CInt(If(drInvoiceMain.Item("GST Rate").ToString.Equals(""), "0", drInvoiceMain.Item("GST Rate").ToString))
1 Like

Hi @kumar.varun2 , @mitul_choudhary

Try these

CInt(((Double.Parse(drInvoiceMain.Item(“IGST Amount”).ToString, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowParentheses, new CultureInfo(“en-US”))+Double.Parse(drInvoiceMain.Item(“SGST / UT GST Amount”).ToString, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowParentheses, new CultureInfo(“en-US”))+Double.Parse(drInvoiceMain.Item(“CGST Amount”).ToString, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowParentheses, new CultureInfo(“en-US”)))/Double.Parse(drInvoiceMain.Item(“Taxable Value”).ToString, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowParentheses, new CultureInfo(“en-US”)))*100)=Int32.Parse(drInvoiceMain.Item(“GST Rate”).ToString, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowParentheses, new CultureInfo(“en-US”))

@mitul_choudhary Did it work?

Yes thanks a lot :slight_smile:

1 Like

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