以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 我真不明! (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=151777) |
-- 作者:采菊东篱下 -- 发布时间:2020/7/3 10:01:00 -- 我真不明! 帮助里 Ceiling 返回大于或等于指定数字的最小整数。 例如: Dim Val As
Double = 123.1 执行后变量Lng的值将等于124。 我执行messagebox.show(math.Ceiling(1 \\ 2))结果是0,不是应为1吗?怎么变0了!
|
-- 作者:有点蓝 -- 发布时间:2020/7/3 10:16:00 -- http://www.foxtable.com/webhelp/topics/0218.htm messagebox.show(math.Ceiling(1 / 2))
|
-- 作者:采菊东篱下 -- 发布时间:2020/7/3 10:16:00 -- 哦,我明白了,我用了1\\2,不是1/2 |
-- 作者:采菊东篱下 -- 发布时间:2020/7/3 10:47:00 -- 其实这个疑问是这帖: 72楼,你帮我写的代码,我今早发现有问题查出来的,发这帖后猛然醒悟,用的是“\\”,不是“/”,看你的回答也是这样指出,我当时对你给的代码没怀疑,后来发现得出的结果不对,就硬把dr("桌号") = math.Ceiling(i2 \\ 2)改成dr("桌号") = math.Ceiling((i2 + 1) \\ 2),显示对了,但问题还没最终解决,这问题应与 dr("排序") = math.Ceiling(i2 / 2)无关了,比赛积分表棋赛名称222,第一轮已经生成9个人,但老人组表就是只显示4行,8个人,少了一个人,一调就报错! Dim qsmc As WinForm.ComboBox = e.Form.Controls("棋赛名称") Dim di1 As String = qsmc.Value Dim m As WinForm.TextBox = e.Form.Controls("第几轮") Dim di2 As String = m.Value Dim bsrq As WinForm.DateTimePicker = e.Form.Controls("rq") Dim di3 As Date = bsrq.Value If bsrq.text ="" Then messagebox.show("请选择日期") Return End If Dim fz As WinForm.ComboBox = e.Form.Controls("fenzhu") Dim Str As String = fz.Value Dim dr As DataRow = DataTables("比赛积分").SQLfind("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'") Dim a As String = Cstr(Val(di2)-1) Dim i2 As Integer = 1 Dim ii2 As Integer = 1 Dim dts As List(of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [身份] = \'参赛人\' And [分组] = \'" & Str & "\'") DataTables("比赛积分").DeleteFor("棋赛名称 is null and 第几轮比赛 is null And [分组] = \'" & Str & "\'") Dim cnt As Integer cnt = DataTables("比赛积分").Compute("Count([姓名])", "[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'") If di2 =1 And cnt = 0 Then Do While dts.Count > 0 Dim idx As Integer = rand.Next(0,dts.Count) dr = DataTables("比赛积分").AddNew dr("排序") = math.Ceiling(i2 / 2) dr("日期") = di3 dr("棋赛名称") = di1 dr("第几轮比赛") = di2 dr("编号") = dts(idx)("编号") dr("姓名") = dts(idx)("姓名") dr("轮赛次数值转换") = Val(di2) dr("分组") = Str dts.RemoveAt(idx) i2 + = 1 Loop DataTables("比赛积分").Load DataTables("比赛积分").Save() DataTables("老人组").DataRows.Clear Dim drs1 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'","","日期 Desc,分组,排序 Desc") For i As Integer = 0 To drs1.count - 1 Step 2 If i + 1 <= drs1.Count - 1 Dim nr As DataRow = DataTables("老人组").AddNew nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") nr("黑方_编号") = drs1(i+1)("编号") nr("黑方_姓名") = drs1(i+1)("姓名") End If Next [此贴子已经被作者于2020/7/3 10:53:19编辑过]
|
-- 作者:采菊东篱下 -- 发布时间:2020/7/3 20:28:00 -- 比赛积分表棋赛名称222,第一轮已经生成9个人,但老人组表只显示4行,8个人,少了一个人,我改了一下不成功,应该红色部份有问题,请教这代码应怎么写呢? Dim qsmc As WinForm.ComboBox = e.Form.Controls("棋赛名称") Dim di1 As String = qsmc.Value Dim m As WinForm.TextBox = e.Form.Controls("第几轮") Dim di2 As String = m.Value Dim bsrq As WinForm.DateTimePicker = e.Form.Controls("rq") Dim di3 As Date = bsrq.Value If bsrq.text ="" Then messagebox.show("请选择日期") Return End If Dim fz As WinForm.ComboBox = e.Form.Controls("fenzhu") Dim Str As String = fz.Value Dim dr As DataRow = DataTables("比赛积分").SQLfind("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'") Dim a As String = Cstr(Val(di2)-1) Dim i2 As Integer = 1 Dim ii2 As Integer = 1 Dim dts As List(of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [身份] = \'参赛人\' And [分组] = \'" & Str & "\'") DataTables("比赛积分").DeleteFor("棋赛名称 is null and 第几轮比赛 is null And [分组] = \'" & Str & "\'") Dim cnt As Integer cnt = DataTables("比赛积分").Compute("Count([姓名])", "[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'") If di2 =1 And cnt = 0 Then Do While dts.Count > 0 Dim idx As Integer = rand.Next(0,dts.Count) dr = DataTables("比赛积分").AddNew dr("排序") = math.Ceiling(i2 / 2) dr("日期") = di3 dr("棋赛名称") = di1 dr("第几轮比赛") = di2 dr("编号") = dts(idx)("编号") dr("姓名") = dts(idx)("姓名") dr("轮赛次数值转换") = Val(di2) dr("分组") = Str dts.RemoveAt(idx) i2 + = 1 Loop DataTables("比赛积分").Load DataTables("比赛积分").Save() DataTables("老人组").DataRows.Clear Dim drs1 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'","","日期 Desc,分组,排序 Desc") Dim i As Integer For i = 0 To drs1.Count Step 2 Dim nr As DataRow = DataTables("老人组").AddNew If i + 1 <= drs1.Count nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") nr("黑方_编号") = drs1(i+1)("编号") nr("黑方_姓名") = drs1(i+1)("姓名") End If Dim count7 As Integer = DataTables("老人组").Compute("Count([姓名])","[红方_姓名] Is Not Null") Dim count8 As Integer = DataTables("老人组").Compute("Count([姓名])","[黑方_姓名] Is Not Null") If i = drs1.Count And count7 > count8 Then nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") nr("黑方_编号") = Nothing nr("黑方_姓名") = Nothing End If Next [此贴子已经被作者于2020/7/4 8:50:05编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/7/4 9:50:00 -- For i = 0 To drs1.Count Step 2 Dim nr As DataRow = DataTables("老人组").AddNew nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") If i + 1 <= drs1.Count nr("黑方_编号") = drs1(i+1)("编号") nr("黑方_姓名") = drs1(i+1)("姓名") End If
|
-- 作者:采菊东篱下 -- 发布时间:2020/7/4 10:23:00 -- 原来就是这样啊,没有了最后一个没对手的排座,我想了一下,能不能这样,只是想法,还不正确 Dim drs1 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'","","日期 Desc,分组,排序 Desc") Dim i As Integer For i = 0 To drs1.Count Dim nr As DataRow = DataTables("老人组").AddNew If i = drs1.Count If drs1.Count Mod 2 = 0 Then nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") Dim count7 As Integer = 0 count7 + = 1 Continue For End If nr("黑方_编号") = drs1(i)("编号") nr("黑方_姓名") = drs1(i)("姓名") Dim count8 As Integer = 0 count8 + = 1 End If If i = drs1.Count And count7 > count8 Then Exit For End If nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") nr("黑方_编号") = Nothing nr("黑方_姓名") = Nothing Next |
-- 作者:采菊东篱下 -- 发布时间:2020/7/4 10:24:00 -- 有事要两天后再看了,两天后见,谢谢。 |
-- 作者:采菊东篱下 -- 发布时间:2020/7/5 23:52:00 -- 以下是引用有点蓝在2020/7/4 9:50:00的发言:
For i = 0 To drs1.Count Step 2 Dim nr As DataRow = DataTables("老人组").AddNew nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") If i + 1 <= drs1.Count nr("黑方_编号") = drs1(i+1)("编号") nr("黑方_姓名") = drs1(i+1)("姓名") End If 你这段代码直接报错,不让保存。
|
-- 作者:采菊东篱下 -- 发布时间:2020/7/6 8:34:00 -- 改成这样不报错了 Dim drs1 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' And [分组] = \'" & Str & "\'","","日期 Desc,分组,排序 Desc") Dim nr As DataRow For i As Integer = 0 To drs1.Count - 1 If i <= drs1.Count And i Mod 2 = 0 Then nr = DataTables("老人组").AddNew nr("桌号") = drs1(i)("排序") nr("红方_编号") = drs1(i)("编号") nr("红方_姓名") = drs1(i)("姓名") ElseIf i <= drs1.Count And i Mod 2 = 1 Then nr("黑方_编号") = drs1(i)("编号") nr("黑方_姓名") = drs1(i)("姓名") End If Next [此贴子已经被作者于2020/7/6 20:11:09编辑过]
|