以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  选择框里面的<, > ,= ,<=, >=,值如何体现在代码中呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=169524)

--  作者:cnsjroom
--  发布时间:2021/6/19 16:22:00
--  选择框里面的<, > ,= ,<=, >=,值如何体现在代码中呢?
选择框c1里面的<, > ,= ,<=, >=,值如何体现在代码中呢?
Dim c1 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
    Dim tx2 As WinForm.TextBox = e.Form.Controls("TextBox2")
    If tel1 < tx2.Text Then   选择框c1里面的<, > ,= ,<=, >=,值如何体现在这里的代码中呢?
        If FileSys.FileExists(file) Then \'如果指定的文件存在
            FileSys.CopyFile(file,"d:\\数据\\" & FileSys.Getname(File),True) \'则彻底删除之
        End If
    End If

--  作者:有点蓝
--  发布时间:2021/6/19 16:30:00
--  
那要使用动态函数了:http://www.foxtable.com/webhelp/topics/1487.htm



--  作者:cnsjroom
--  发布时间:2021/6/19 18:55:00
--  回复:(有点蓝)那要使用动态函数了:http://www.fox...
Dim Code As String
Code = "Dim c1 As WinForm.ComboBox=e.Form.Controls("ComboBox2")" & vbcrlf
Code = Code & "Dim tx2 As WinForm.TextBox = e.Form.Controls("TextBox2")" & vbcrlf
Code = Code & "If tel1"& tx2.text &"tx2.Text Then"" & vbcrlf
Code = Code & "If FileSys.FileExists(file) Then" & vbcrlf
Code = Code & "FileSys.CopyFile(file,"d:\\数据\\" & FileSys.Getname(File),True)" & vbcrlf
Code = Code & "End If" & vbcrlf
Code = Code & "End If" & vbcrlf
Functions.Add("Sum",Code)
Functions.Complie()

这样每  不能成功保存  麻烦老师帮忙看看是不是哪里没有写对呢

提示字符常量必须正好包含一个字符
[此贴子已经被作者于2021/6/19 19:17:19编辑过]

--  作者:有点蓝
--  发布时间:2021/6/20 19:56:00
--  
参考:http://www.foxtable.com/webhelp/topics/0211.htm

Code = "Dim c1 As WinForm.ComboBox=e.Form.Controls(""ComboBox2"")" & vbcrlf

--  作者:cnsjroom
--  发布时间:2021/6/20 20:40:00
--  回复:(有点蓝)参考:http://www.foxtable.com/webh...
红色部分代码提示未定义  老师有没有办法呢?

c2.value  有  <    >    <=    >=   =   <> 等
Dim Code As String
Code = "Dim c2 As WinForm.ComboBox=e.Form.Controls(""ComboBox2"")" & vbcrlf
Code = Code & "Dim tx2 As WinForm.TextBox = e.Form.Controls(""TextBox2"")" & vbcrlf
Code = Code & "If tel1" & c2.value & tx2.Text & "Then"" & vbcrlf
Code = Code & "If FileSys.FileExists(file) Then" & vbcrlf
Code = Code & "FileSys.CopyFile(file,""d:\\数据\\"" & FileSys.Getname(File),True)" & vbcrlf
Code = Code & "End If" & vbcrlf
Code = Code & "End If" & vbcrlf
output.show(Code)

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

[此贴子已经被作者于2021/6/20 20:46:52编辑过]

--  作者:有点蓝
--  发布时间:2021/6/20 21:14:00
--  
要按自定义函数的标准用法定义代码。先建一个函数,把代码放到函数里,测试通过后再用到动态函数里

dim e = args(0)
dim tel1 as string = args(1)
Dim c1 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
……


调用此函数:

Functions.Execute("Sum",e,tel1)


--  作者:cnsjroom
--  发布时间:2021/6/20 23:57:00
--  回复:(有点蓝)要按自定义函数的标准用法定义代码。...
还是不大明白怎么写哦  劳烦老师辛苦下  帮忙看看怎么写  谢谢 我也学习一下
--  作者:有点蓝
--  发布时间:2021/6/21 8:29:00
--  
先学会使用自定义函数:http://www.foxtable.com/webhelp/topics/1486.htm
--  作者:y2287958
--  发布时间:2021/6/21 14:38:00
--  
如果还不懂自定义函数,可根据“<, > ,= ,<=, >=”这几种情况直接写代码即可。
--  作者:cnsjroom
--  发布时间:2021/6/24 8:35:00
--  回复:(有点蓝)先学会使用自定义函数:http://www.f...
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.5.29.8
错误所在事件:自定义函数,sx
详细错误信息:
调用的目标发生了异常。
从字符串“1991-01-16=1990”到类型“Boolean”的转换无效。
输入字符串的格式不正确。

Dim t3 As WinForm.TextBox = e.Form.Controls("单元格行")
Dim t4 As WinForm.TextBox = e.Form.Controls("单元格列")
Dim t5 As WinForm.TextBox = e.Form.Controls("文件目录")
Dim t6 As WinForm.TextBox = e.Form.Controls("单元格新值")
Dim t7 As WinForm.TextBox = e.Form.Controls("运行状态")
Dim js As WinForm.Label = e.Form.Controls("计数")
Dim mb As WinForm.TextBox = e.Form.Controls("目标目录")
Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim mulu As WinForm.RadioButton = e.Form.Controls("筛选后打开目标目录")
For Each File As String In FileSys.GetFiles(t5.value)
    Dim ifo As new FileInfo(File)
    If ifo.Name.Contains("~$") Then
    Else
        If ifo.Extension.Contains("xlsx") Then
            Dim App As New MSExcel.Application
            Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(file)
            Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
            Dim Rg As MSExcel.Range = Ws.Cells(cint(t3.value),cint(t4.value)).offset(-1)
            Dim abcd As String=Rg.Value
            Functions.Execute("sx",t5.text,abcd,cm.text,t6.text,mb.text)
        End If
    End If
Next

sx内部函数代码:
\'\'\'
Dim e = args(0)
Dim tel1 As String = args(1)
Dim tel2 As String = args(2)
Dim tel3 As String = args(3)
Dim tel4 As String = args(4)
If  tel1 & tel2 & tel3 Then
    If FileSys.FileExists(e) Then
        MessageBox.Show("1")
        FileSys.CopyFile(e, tel4 & FileSys.Getname(e),True)
    End If
End If