我在我的應用程序中有下面的代碼...沒有聲明爲整數,所以我不明白或看到問題可能在哪裏......它說:從字符串轉換爲Integer類型無效
從字符串「9838聯合路47」轉換到類型「整數」是無效的。
地址流經整個函數作爲字符串我認爲它可以得到改變在某種程度上是在函數調用的唯一的地方......下面是拋出異常的功能。接着,它返回地址功能...誤差來源於 _holder = item.bill_to.remove(地址)線
For Each item In _QuickImport
Dim BusinessName As String = Nothing
Dim CustomerName As String = " "
_Id = item.id
If Not String.IsNullOrEmpty(item.Customer) Then
Dim _holder As String = String.Empty
Dim _contact_ As String = item.Contact
Dim _address_ As String = String.Empty
If item.Bill_to.Contains(_contact_) Then
_holder = item.Bill_to.Replace(_contact_, " ")
End If
If Not String.IsNullOrEmpty(_holder) Then
If item.Bill_to.Contains("Co Rd") Then
_address_ = ExtractAddressWithCoRd(_holder)
End If
Else
If item.Bill_to.Contains("Co Rd") Then
_address_ = ExtractAddressWithCoRd(item.Bill_to)
End If
End If
If Not String.IsNullOrWhiteSpace(item.Customer) Then
If item.Customer.Contains(":") Then
BusinessName = item.Customer.Split(":")(0)
CustomerName = item.Customer.Split(":")(1)
Else
CustomerName = item.Customer
End If
End If
If Not String.IsNullOrEmpty(BusinessName) Then
If item.Bill_to.Contains(BusinessName) Then
_holder = item.Bill_to.Replace(BusinessName, " ")
End If
End If
Dim _Id_ As Integer = _Id
If Not String.IsNullOrWhiteSpace(_holder) Then
Dim _check As Boolean = True
_check = ValidZip(_holder)
If _check = True Then
If Not String.IsNullOrEmpty(_address_) Then
_holder = Convert.ToString(_holder)
_address_ = Convert.ToString(_address_)
_holder = item.Bill_to.Remove(_address_)
End If
parseAddress(_holder, _Id)
另一個功能是:
Private Function ExtractAddressWithCoRd(ByVal input As String) As String
Dim add1 As String = String.Empty
Dim add2 As String = String.Empty
Dim parts() As String = input.Split(" "c)
For i As Integer = 0 To parts.Length - 1
If parts(i) = "Co" AndAlso i > 0 Then
add1 = parts(i - 1)
ElseIf parts(i) = "Rd" AndAlso i < parts.Length - 1 Then
add2 = parts(i + 1)
End If
Next
Return add1 + " Co Rd " + add2
End Function
這是我想的東西是越來越變爲一個整數值......但這一切聲明爲字符串,以及...
任何想法????
好東西...我想這可能是它是什麼,但它以爲我已經使用刪除其他地方一樣,....謝謝多的幫助... – Skindeep2366