循环内循环的问题 [英] Problem with Loop inside loop
本文介绍了循环内循环的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串变量p_text =} {X = 45,Y = 65} {X = 59,Y = 65} {X = 59,Y = 79} {X = 45,Y = 79} {"
I have a string variable p_text = "}{X=45,Y=65}{X=59,Y=65}{X=59,Y=79}{X=45,Y=79}{"
Dim p_text As String
Dim s1_texts As String()
Dim s2_texts As String()
Dim s3_texts As String()
s1_texts = Split(p_text, "}{")
Dim numi As Integer = 0
Dim numj As Integer = 0
Dim numk As Integer = 0
Do Until numi = s1_texts.Length - 1
If s1_texts(numi) = "" Then
numi += 1
Else
s2_texts = Split(s1_texts(numi), ",")
Do Until numj = s2_texts.Length - 1
If s2_texts(numj) = "" Then
numj += 1
Else
s3_texts = Split(s2_texts(numj), "=")
Do Until numk = s3_texts.Length - 1
TextBox4.Text = TextBox4.Text & s3_texts(numk) & vbCrLf
numk += 1
Loop
numj += 1
End If
Loop
numi += 1
End If
Loop
我希望TextBox4显示-
And I want TextBox4 to show-
X
45
Y
65
x
59
Y
65
.......
但是我只能得到
x
x
x
...
问题出在哪里?
推荐答案
我有一个字符串变量p_text =} {X = 45,Y = 65} {X = 59,Y = 65} {X = 59,Y = 79} {X = 45,Y = 79} { "问题出在哪里?
I have a string variable p_text = "}{X=45,Y=65}{X=59,Y=65}{X=59,Y=79}{X=45,Y=79}{"Where is the problem?
使用For/Each代替带计数的do循环.
Use For/Each instead of a do loop with counting.
For Each s1_texts As String In Split(p_text, "}{")
For Each s2_texts As String In Split(s1_texts, ",")
For Each s3_texts As String In Split(s2_texts, "=")
If s3_texts <> "" Then
TextBox4.Text &= s3_texts & vbCrLf
End If
Next
Next
Next
这篇关于循环内循环的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文