Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
在生成“课时名单”设计中,希望“性质”列的值是“周六下午”改为“补课”,“周六晚上”改为“辅导”,“周日上午”改为“守班”,“周日下午”改为“补课”。如何对下列Tables("课时名单").Rows(i)("性质") = Values(1)中的Values(1)进行控制?原设计代码如下:
'生成"课时名单"表
Dim s As Date = Date.Now()
Dim ksmd As New DataTableBuilder("课时名单")
ksmd.AddDef("姓名", GetType(String), 15)
ksmd.AddDef("性质", GetType(String), 15)
ksmd.AddDef("星期", GetType(String), 15)
ksmd.AddDef("计分", GetType(Integer))
ksmd.Build()
'生成"课时名单"数据
Dim Values() As String
Dim n As Integer = Tables("补课").rows.count
Dim n1 As Integer
for Each dc as Datacol in DataTables("补课").Datacols
if dc.name <> "班级" Then
n1 = n1 +1
dim f As New Filler
f.SourceTable = DataTables("补课") '指定数据来源
f.SourceCols = dc.name '指定数据来源列
f.DataTable = DataTables("课时名单") '指定数据接收表
f.DataCols = "姓名" '指定数据接收列
f.ExcludeNullValue=true
f.Distinct = false
f.Fill() '填充数据
Values = dc.name.split("_")
For i As integer = (n*n1)-n to Tables("课时名单").rows.count -1
Tables("课时名单").Rows(i)("星期") = Values(0)
Tables("课时名单").Rows(i)("性质") = Values(1)
Tables("课时名单").Rows(i)("计分") = 1
Next
end if
Next
DataTables("课时名单").DeleteFor("[姓名] Is Null")
Messagebox.Show("处理完毕! 耗时: " & (Date.Now -s).TotalSeconds)
(注:不想生成“课时名单”后,再遍历替换)
下载信息 [文件大小: 下载次数: ] | |
点击浏览该文件:管理项目1.table |
感觉用 select case 比较好
'生成"课时名单"表
Dim s As Date = Date.Now()
Dim ksmd As New DataTableBuilder("课时名单")
ksmd.AddDef("姓名", GetType(String), 15)
ksmd.AddDef("性质", GetType(String), 15)
ksmd.AddDef("星期", GetType(String), 15)
ksmd.AddDef("计分", GetType(Integer))
ksmd.Build()
'生成"课时名单"数据
Dim Values() As String
Dim n As Integer = Tables("补课").rows.count
Dim n1 As Integer
for Each dc as Datacol in DataTables("补课").Datacols
Dim T As Table = Tables("课时名单")
if dc.name <> "班级" Then
n1 = n1 +1
dim f As New Filler
f.SourceTable = DataTables("补课") '指定数据来源
f.SourceCols = dc.name '指定数据来源列
f.DataTable = DataTables("课时名单") '指定数据接收表
f.DataCols = "姓名" '指定数据接收列
f.ExcludeNullValue=true
f.Distinct = false
f.Fill() '填充数据
Values = dc.name.split("_")
For i As integer = (n*n1)-n to T.rows.count -1
T.Rows(i)("星期") = Values(0)
Select Case Values(1)
Case "周六下午","周日下午"
Values(1) = "补课"
Case "周六晚上"
Values(1) = "辅导"
Case "周日上午"
Values(1) = "守班"
End Select
T.Rows(i)("性质") = Values(1)
T.Rows(i)("计分") = 1
Next
end if
Next
DataTables("课时名单").DeleteFor("[姓名] Is Null")
Messagebox.Show("处理完毕! 耗时: " & (Date.Now -s).TotalSeconds)
呵呵,我不认为是iif的问题,iif同样可以完成,如:
Values(1) = iif(Values(1)="周六下午","补课",iif(Values(1)= "周日下午","补课",iif(Values(1)="周六晚上","辅导",iif(Values(1)="周日上午","守班",Values(1)))))