我需要拉数据,然后输出两行。输入为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