我需要拉數據,然後輸出兩行。輸入爲STREET/CITY/STATE/ZIP。我的下面的代碼適用於街道和城市,在STATE它發送ST/ZIP輸出。我似乎可以找到我的錯誤?代碼如下:VB insrt需要從字符串中拉文本
Private Sub btnEnter_Click(sender As Object, e As EventArgs) Handles btnEnter.Click
Dim Street As String, City As String, State As String, Zip As String
Dim npos As Integer = 0, npos2 As Integer, npos3 As Integer = 0
npos = (InStr(txtAddress.Text, "/"))
npos2 = (InStr((npos + 1), txtAddress.Text, "/"))
npos3 = (InStr((npos2 + 1), txtAddress.Text, "/"))
Street = (Mid(txtAddress.Text, 1, (npos - 1)))
City = (Mid(txtAddress.Text, (npos + 1), (npos2 - npos - 1)))
State = (Mid(txtAddress.Text, (npos2 + 1), (npos3 - 1)))
TextBox1.Text = Street & vbCrLf & City & " " & State
End Sub
我建議使用[String.Split方法](https://msdn.microsoft.com/en-us/library/system.string.split(V = vs.110)的.aspx) – bansi 2015-03-02 04:59:01