以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多分支条件问题,求解 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69032) |
||||
-- 作者:youkacard -- 发布时间:2015/5/29 10:53:00 -- 多分支条件问题,求解 Dim Result As String \'储存生成结果 Dim Start As String = e.Form.Controls("TextBox1").Value \'起始号码 Dim Number As String = e.Form.Controls("TextBox2").Value \'生成数量 Dim nEnd As Integer = CInt(Start) + CInt(Number) - 1 \'结束号码 Dim fmt As String = "".PadLeft(Start.Length,"0") \'获取起始字符占位 Dim tj() As String = e.Form.Controls("TextBox5").Value.Split(",") \'条件输入 Dim gds As String = e.Form.Controls("TextBox3").Value \'获取固定首位字符 Dim gdw As String = e.Form.Controls("TextBox3").Value \'获取固定尾部字符 For i As Integer = Start To nEnd If e.Form.Controls("CheckBox1").Checked And tj.Length > 0 Then \'尾数跳过条件成立 If Array.LastIndexOf(tj,CStr(i Mod 10)) = -1 Then Result &= Format(i,fmt) & vbcrlf End If Else If e.Form.Controls("CheckBox2").Checked And tj.Length > 0 Then \'全部跳过条件成立 Dim b As Boolean = True For s As Integer = 0 To tj.Length - 1 If CStr(i).Contains(tj(s)) Or Format(i,fmt).Contains(tj(s)) Then b = False End If Next If b Then Result &= Format(i,fmt) & vbcrlf End If Else If e.Form.Controls("CheckBox3").Checked And tj.Length > 0 Then \'重复条件成立 For x As Integer = 1 To tj(0) Result &= Format(i,fmt) & vbcrlf Next Else Result &= Format(i,fmt) & vbcrlf End If Next Dim save As New SaveFileDialog save.Filter = "文本文件|*.txt" save.Title = "保存数据" save.OverwritePrompt = True If save.ShowDialog = DialogResult.OK Then FileSys.WriteAllText(save.FileName,Result,False,Encoding.Unicode) End If -----------------------------------------------------------------------分割线--------------------------------------------------------------------------- 红色标注的那句代码,按照正常情况下,应该是前面三个条件不成立的情况下,执行这一局才对,可是执行的时候为什么报错呢? 报错情况如下:
|
||||
-- 作者:大红袍 -- 发布时间:2015/5/29 10:56:00 -- 加入msgbox调试一下
http://www.foxtable.com/help/topics/1485.htm
|
||||
-- 作者:youkacard -- 发布时间:2015/5/29 11:05:00 --
版主,能帮我看下吗?,刚才调试了下,还是没找出来 现在就是想三个条件不成立的情况下,正常生成流水号
|
||||
-- 作者:大红袍 -- 发布时间:2015/5/29 11:20:00 -- Dim Result As String \'储存生成结果 For i As Integer = Start To nEnd Dim save As New SaveFileDialog |
||||
-- 作者:youkacard -- 发布时间:2015/5/29 15:28:00 -- 谢谢版主,再问个问题,按照代码,跳过指定号码之后,总数就不够了,有什么办法能让循环够数量,例如: Dim qs As Integer = 1 Dim js As Integer = 10 Dim s As Integer \'统计跳过的次数 For i As Integer = qs To js + s If CStr(i).Contains("4") Then s = s + 1 Else Output.Show(i & vbcrlf) End If Next 这样写好像不起作用
|
||||
-- 作者:大红袍 -- 发布时间:2015/5/29 15:36:00 -- Dim qs As Integer = 1 Dim js As Integer = 10 Dim s As Integer = 0 Dim i As Integer = qs Do While s <= js - qs If CStr(i).Contains("4") = False Then s += 1 Output.Show(i & vbcrlf) End If i = i + 1 Loop |