以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]批量设置要显示的列及其列宽能否简化?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=162142)

--  作者:cqlpjks
--  发布时间:2021/4/7 9:40:00
--  [求助]批量设置要显示的列及其列宽能否简化?
Dim mbs() As String = {"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}
For Each mb As String In mbs
      Tables( "总分2021级目标").SetColVisibleWidth("单位|70|部别|50|年级|50|单位代码|44|目标1|50|目标2|50|目标3|50|目标4|50|目标9|50|目标10|50|目标5|50|目标6|50|目标7|50|目标8|50")
Next

因红色部分{"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}列宽都是50,能否简化用“mb”代替?若能如何修改代码?请指教。谢谢!

或者:
For i As Integer = 1 To 8
"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8" 变成 “目标” & i
[此贴子已经被作者于2021/4/7 9:42:26编辑过]

--  作者:有点蓝
--  发布时间:2021/4/7 10:01:00
--  
Dim mbs() As String = {"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}
dim s as string = "单位|70|部别|50|年级|50|单位代码|44|" & string.join("|50|",mbs) & "|50"
msgbox(s)

--  作者:cqlpjks
--  发布时间:2021/4/7 10:39:00
--  
谢谢!
Dim mbs() As String = {"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}
Tables( "总分2016级目标").SetColVisibleWidth("单位|70|部别|50|年级|50|单位代码|44|" & String.join("|50|",mbs) & "|50")

--  作者:cqlpjks
--  发布时间:2021/4/7 15:57:00
--  
Dim mbs() As String = {"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}
dim s as string = "单位|70|部别|50|年级|50|单位代码|44|" & String.join("|50|",mbs) & "|50"
For i As Integer = 1 To 8
mbs不能直接用“目标” & i代替吗?请指教。谢谢!

--  作者:有点蓝
--  发布时间:2021/4/7 16:05:00
--  
没看懂,要做什么?
--  作者:cqlpjks
--  发布时间:2021/4/7 16:15:00
--  
Dim mbs() As String = {"目标1","目标2","目标3","目标4","目标5","目标6","目标7","目标8"}
dim s as string = "单位|70|部别|50|年级|50|单位代码|44|" & string.join("|50|",mbs) & "|50"
msgbox(s)
再简化:
For i As Integer = 0 To 8
      dim s as string = "单位|70|部别|50|年级|50|单位代码|44|" & string.join("|50|","目标“& i) & "|50"
      msgbox(s)
Next
报错:类型“string”的值无法转换为string的 1 维数组”
不得行,如何修改代码?请指教。谢谢!

[此贴子已经被作者于2021/4/7 16:18:23编辑过]

--  作者:有点蓝
--  发布时间:2021/4/7 16:18:00
--  
这个意思?

dim s as string = "单位|70|部别|50|年级|50|单位代码|44"
For i As Integer = 0 To 8
      dim s as string = s & "|目标“ & i & "|50"
Next
msgbox(s)

--  作者:cqlpjks
--  发布时间:2021/4/7 16:32:00
--  
Dim mbs As String = "单位|70|部别|50|年级|50|单位代码|44"
For i As Integer = 1 To 8
    Dim s As String = mbs & "|目标" & i & "|50"    
    msgbox(s)
Next

不得行,还是逐一显示 “单位|70|部别|50|年级|50|单位代码|44|目标1”、“单位|70|部别|50|年级|50|单位代码|44|目标2”、“单位|70|部别|50|年级|50|单位代码|44|目标3”...

--  作者:有点蓝
--  发布时间:2021/4/7 16:35:00
--  
Dim s As String = "单位|70|部别|50|年级|50|单位代码|44"
For i As Integer = 0 To 8
      s = s & "|目标" & i & "|50"
Next
msgbox(s)