以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 不知道为什么每次运行这个代码都会卡死? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69643) |
|
-- 作者:youkacard -- 发布时间:2015/6/8 16:19:00 -- 不知道为什么每次运行这个代码都会卡死? Dim sx() As String = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"} Dim i As Integer = 1 Dim x As Integer = 1 Dim y As Integer = 0 Dim result As String Do While x < 3600 If CStr(i).Contains("4") = False Then If x Mod 30 = 0 Then y = y + 1 End If If y > 11 Then y = 0 End If If y < 12 Then result &= "NO." & Format(i,"00000000") & "-" & sx(y) & vbcrlf i = i + 1 End If x = x + 1 End If Loop FileSys.WriteAllText("c:\\test.txt",result,False,Encoding.Default) 求指点问题出在哪里?我自己测试了下 好像是 CStr(i).Contains("4") = False 这个条件加上去之后就死,但是好像没问题啊
|
|
-- 作者:youkacard -- 发布时间:2015/6/8 16:41:00 -- 召唤版主 |
|
-- 作者:Bin -- 发布时间:2015/6/8 16:42:00 -- X自增放到IF条件内. 那永远都不会触发.死循环了 自增请放到条件外
|
|
-- 作者:大红袍 -- 发布时间:2015/6/8 16:46:00 -- 不要乱写代码,直接说你的逻辑。 |
|
-- 作者:youkacard -- 发布时间:2015/6/8 16:46:00 -- 可是放在条件外,到3就断开了,不会继续执行了 |
|
-- 作者:大红袍 -- 发布时间:2015/6/8 16:50:00 -- 直接说你要做什么啊 |
|
-- 作者:youkacard -- 发布时间:2015/6/8 16:58:00 -- 从NO.0000001开始顺延3600个,包含4跳过,每30个号码就是一个生肖,比方说生肖鼠的号段是NO.0000001-NO.00000033...一次类推,12个剩下分完360个数据后,又开始分配剩下的数据,直到分完3600个数据 |
|
-- 作者:大红袍 -- 发布时间:2015/6/8 17:12:00 -- Dim sx() As String = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"} Dim result As String = "" Dim i As Integer = 1 Dim count As Integer = 1 Dim sidx As Integer = 0 Do While i <= 3600 If CStr(i).Contains("4") = False Then result &= "NO." & Format(i,"00000000") & "-" & sx(sidx) & vbcrlf If count Mod 30 = 0 Then sidx += 1 If sidx > 11 Then sidx = 0 End If End If count += 1 End If i = i + 1 Loop FileSys.WriteAllText("c:\\test.txt",result,False,Encoding.Default) |
|
-- 作者:youkacard -- 发布时间:2015/6/8 17:27:00 -- 以下是引用大红袍在2015/6/8 17:12:00的发言: Dim sx() As String = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"} Dim result As String = "" Dim i As Integer = 1 Dim count As Integer = 1 Dim sidx As Integer = 0 Do While i <= 3600 If CStr(i).Contains("4") = False Then result &= "NO." & Format(i,"00000000") & "-" & sx(sidx) & vbcrlf If count Mod 30 = 0 Then sidx += 1 If sidx > 11 Then sidx = 0 End If End If count += 1 End If i = i + 1 Loop FileSys.WriteAllText("c:\\test.txt",result,False,Encoding.Default) 但是按照这样,生成出来的数据不够3600个,只有2500多 |
|
-- 作者:大红袍 -- 发布时间:2015/6/8 17:30:00 -- Dim sx() As String = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"} Dim result As String = "" Dim i As Integer = 1 Dim count As Integer = 1 Dim sidx As Integer = 0 Dim maxcount As Integer = 3600 Do While i <= maxcount If CStr(i).Contains("4") = False Then result &= "NO." & Format(i,"00000000") & "-" & sx(sidx) & vbcrlf If count Mod 30 = 0 Then sidx += 1 If sidx > 11 Then sidx = 0 End If End If count += 1 Else maxcount += 1 End If i = i + 1 Loop FileSys.WriteAllText("c:\\test.txt",result,False,Encoding.Default) |