我有这方面的for循环:退出对于vb.net不会退出
For x = search_phone.Length To 0 Step -1
For m = 1 To number_call_costs
If search_phone.Substring(0, x) = call_costs_data(m, 2) Then
match = True
customer_cost = callcost_lookup("sequence", call_costs_data(m, 1), customer_sequence, "cost")
customer_connection = callcost_lookup("sequence", call_costs_data(m, 1), customer_sequence, "connection")
description = call_costs_data(m, 3)
MsgBox(call_costs_data(m, 3))
Exit For
Exit For
End If
Next
Next
我与测试的数据是:
search_phone = '101'
call_costs_data(m, 2) = one row is '1' and another row is '101'
其在循环,但其匹配search_phone
到101
不退出,因为它再次匹配到1
那第二个出口将不会达到。在x循环的末尾,尝试'If match = True Then Exit For'。 – LarsTech
啊当然!卫生署!所以在第一个“Next”之后放置另一个'Exit For'? – charlie