以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何把vba语言转换成狐表编程语言  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=85565)

--  作者:wu725
--  发布时间:2016/5/28 16:59:00
--  如何把vba语言转换成狐表编程语言

我曾经用电子表格做了一个根据组别序号个数,自动分组,现在想用狐表实现自动分组。如组别相同序号个数小于16,不分组,大于等于16,小于30分两组,分别在组别名称后加1小组,2小组;大于等于31,小于等于45分3个小组,以此类推。不知狐表编写语言是否与vba一样,请老师指点一下。另如何学习狐表编程语言?谢谢!

(如图)
图片点击可在新窗口打开查看此主题相关图片如下:11.png
图片点击可在新窗口打开查看

 

vba语言

 

Sub lqxs()
Dim arr, i&, aa, j&, n&, m&
Dim d, k, t
Set d = CreateObject("Scripting.Dictionary")
Sheet1.Activate
[I2:I2001].ClearContents
arr = [a1].CurrentRegion
For i = 1 To UBound(arr)
    d(arr(i, 1)) = d(arr(i, 1)) & i & ","
Next
k = d.keys: t = d.items
For i = 0 To UBound(k)
    t(i) = Left(t(i), Len(t(i)) - 1)
    If InStr(t(i), ",") Then
        aa = Split(t(i), ",")
        n = UBound(aa) + 1
        If n >= 16 And n <= 30 Then
            For j = 0 To UBound(aa)
                m = m + 1
                If m > 2 Then
                    m = 1
                End If
                If m = 1 Then
                zz = "1组"
                ElseIf m = 2 Then: zz = "2组"
                End If
                Cells(aa(j), 10) = arr(aa(j), 6) & zz
            Next
        ElseIf n >= 31 And n <= 45 Then
            For j = 0 To UBound(aa)
                m = m + 1
                If m > 3 Then
                    m = 1
                End If
                If m = 1 Then
                zz = "1组"
                ElseIf m = 2 Then: zz = "2组"
                ElseIf m = 3 Then: zz = "3组"
                End If
                Cells(aa(j), 10) = arr(aa(j), 6) & zz
           Next
        ElseIf n >= 46 And n <= 60 Then
            For j = 0 To UBound(aa)
                m = m + 1
                If m > 4 Then
                    m = 1
                End If
                If m = 1 Then
                zz = "1组"
                ElseIf m = 2 Then: zz = "2组"
                ElseIf m = 3 Then: zz = "3组"
                ElseIf m = 4 Then: zz = "4组"
                End If
                Cells(aa(j), 10) = arr(aa(j), 6) & zz
            Next

。。。。。。


--  作者:Hyphen
--  发布时间:2016/5/28 17:28:00
--  
Dim xuhao As List(Of String) = DataTables("表A").GetValues("序号")
For Each s As String In xuhao
    Dim drs As List(Of DataRow) = DataTables("表A").Select("序号 = \'" & s &"\'","[_Identify]")
    If drs.Count < 16 Then Continue For
    Dim count = math.Ceiling(drs.Count / 15)
    For i As Integer = 0 To  drs.Count -1 
        drs(i)("分组") = drs(i)("组别") & (i Mod count + 1)
    Next
Next

vb.net和vba语法类似,只是操作表格的方式大不一样,重点看看帮助的编程基础和Foxtable编程这2章

--  作者:wu725
--  发布时间:2016/5/29 11:35:00
--  
谢谢楼主,上名语言执行市提示GetValues不是DataTables成员,无法运行,如果>=16,小于<30可以用我编写vba语言方式吗?
--  作者:大红袍
--  发布时间:2016/5/29 22:53:00
--  
以下是引用wu725在2016/5/29 11:35:00的发言:
谢谢楼主,上名语言执行市提示GetValues不是DataTables成员,无法运行,如果>=16,小于<30可以用我编写vba语言方式吗?

 

去下载最新版本的foxtable,不要用盗版。


--  作者:大红袍
--  发布时间:2016/5/29 22:55:00
--  

如果确实要用旧版本,这样写

 

Dim xuhao As List(Of String) = DataTables("表A").GetUniqueValues("", "序号")
For Each s As String In xuhao
    Dim drs As List(Of DataRow) = DataTables("表A").Select("序号 = \'" & s &"\'","[_Identify]")
    If drs.Count < 16 Then Continue For
    Dim count = math.Ceiling(drs.Count / 15)
    For i As Integer = 0 To  drs.Count -1
        drs(i)("分组") = drs(i)("组别") & (i Mod count + 1)
    Next
Next