我使用了这些代码,但 return 作为无效字符串格式出现错误
I used these codes but return an error as an invalid string Format
我使用了这些代码,但 return 出现错误,因为字符串格式无效。
你能指导我吗?:)
Dim orderRequest As BamboraOrderRequest = New BamboraOrderRequest
orderRequest.id = objCartData.GetOrderNumberWithoutInceasing()
If Session("CardPaymentTotalPrice").ToString().Contains(",") Then
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString().Replace(",", ""))
Else
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString())
End If
orderRequest.currency = "DKK"
根据您提供的信息,尚不清楚错误发生的位置以及给出的值,但您可以尝试按如下方式编辑代码,看看是否有帮助:
Dim orderRequest As BamboraOrderRequest = New BamboraOrderRequest
orderRequest.id = objCartData.GetOrderNumberWithoutInceasing()
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString().Replace(",", ""))
orderRequest.currency = "DKK"
String.Replace 方法仅替换存在的字符,从而消除了对 If
语句的需要。
试试这个,如果它不起作用,请提供有关该问题的更多详细信息。知道 Session("CardPaymentTotalPrice")
returns.
的值也很有帮助
我使用了这些代码,但 return 出现错误,因为字符串格式无效。
你能指导我吗?:)
Dim orderRequest As BamboraOrderRequest = New BamboraOrderRequest
orderRequest.id = objCartData.GetOrderNumberWithoutInceasing()
If Session("CardPaymentTotalPrice").ToString().Contains(",") Then
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString().Replace(",", ""))
Else
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString())
End If
orderRequest.currency = "DKK"
根据您提供的信息,尚不清楚错误发生的位置以及给出的值,但您可以尝试按如下方式编辑代码,看看是否有帮助:
Dim orderRequest As BamboraOrderRequest = New BamboraOrderRequest
orderRequest.id = objCartData.GetOrderNumberWithoutInceasing()
orderRequest.amount = Convert.ToInt32(Session("CardPaymentTotalPrice").ToString().Replace(",", ""))
orderRequest.currency = "DKK"
String.Replace 方法仅替换存在的字符,从而消除了对 If
语句的需要。
试试这个,如果它不起作用,请提供有关该问题的更多详细信息。知道 Session("CardPaymentTotalPrice")
returns.