以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 移动开发-自定义函数衔接 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=114335) |
||
-- 作者:一笑 -- 发布时间:2018/2/3 16:08:00 -- 移动开发-自定义函数衔接 httprequest代码太多,相同自定义函数简化页面,想把一下代码变为自定义函数task: Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim dt1 As New Date(y, m, 1) Dim Filter1 As String Filter1 = "飞行日期 >= #" & dt4 & "#" Dim cnt As Integer = Tables("任务书").Compute("Count([_Identify])",filter1) Dim txt As String = " 截止" & max & y & "今年共" & cnt & "个航段。“ 于是使用: Functions.Execute("task") 但接下代码如下: With wb.AddArticle("page1","ar1") .AddContent(txt) End With 需要引用变量txt,报错(未定义txt),请问有没有其他办法,谢谢! |
||
-- 作者:有点蓝 -- 发布时间:2018/2/3 16:11:00 -- 函数task: Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim dt1 As New Date(y, m, 1) Dim Filter1 As String Filter1 = "飞行日期 >= #" & dt4 & "#" Dim cnt As Integer = Tables("任务书").Compute("Count([_Identify])",filter1) Dim txt As String = " 截止" & max & y & "今年共" & cnt & "个航段。“ return txt 使用: dim txt as string = Functions.Execute("task") With wb.AddArticle("page1","ar1") .AddContent(txt) End With |
||
-- 作者:一笑 -- 发布时间:2018/2/3 17:22:00 -- 谢谢,txt可用了。另外图表也可以吗?函数如下: Dim Chart As New ChartBuilder \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart.PrintWidth = 140 Chart.PrintHeight = 100 Chart.DataSource = "统计表3" \'设置绑定表 Chart.SeriesList.Clear() \'清除图表原来的图系 For Each c As Col In Tables("统计表3").Cols If c.Name <> "机型" Then Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = c.Name \'设置图系的标题 Series.X.DataField = "机型" \'X轴绑定到产品列 Series.Y.DataField = c.Name \'设置Y轴的绑定列 Series.DataLabelText = "{#YVAL}" End If Next return chart 使用: Dim Chart As New ChartBuilder = Functions.Execute("task") 报错。 |
||
-- 作者:有点蓝 -- 发布时间:2018/2/3 17:28:00 -- Dim Chart As ChartBuilder = Functions.Execute("task") |
||
-- 作者:一笑 -- 发布时间:2018/2/3 17:51:00 -- 报错: 无法将类型为“System.String”的对象强制转换为类型“Foxtable.ChartBuilder”。
|
||
-- 作者:有点甜 -- 发布时间:2018/2/4 19:30:00 -- 以下是引用一笑在2018/2/3 17:51:00的发言:
报错: 无法将类型为“System.String”的对象强制转换为类型“Foxtable.ChartBuilder”。
3楼是你函数的代码?如果是,不可能报错。如果不是,贴出你函数的代码。 |
||
-- 作者:一笑 -- 发布时间:2018/2/5 9:06:00 --
Dim Chart As New ChartBuilder \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart.PrintWidth = 140 Chart.PrintHeight = 100 Chart.DataSource = "统计表3" \'设置绑定表 Chart.SeriesList.Clear() \'清除图表原来的图系 For Each c As Col In Tables("统计表3").Cols If c.Name <> "机型" Then Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = c.Name \'设置图系的标题 Series.X.DataField = "机型" \'X轴绑定到产品列 Series.Y.DataField = c.Name \'设置Y轴的绑定列 Series.DataLabelText = "{#YVAL}" End If Next Return Chart
求解,谢谢
|
||
-- 作者:有点甜 -- 发布时间:2018/2/5 9:26:00 -- 执行这个代码,不可能报错
Dim Chart As ChartBuilder = Functions.Execute("task")
实例发上来测试 |
||
-- 作者:一笑 -- 发布时间:2018/2/6 16:43:00 -- 样例做好了,为节约空间,我先贴代码,如还不行我在上传。测试发现如果只返回chart,运行正常;如加上返回引用txt(标蓝处),则报错。 1. 自定义函数代码: Dim Chart As New ChartBuilder Dim Series As WinForm.ChartSeries Chart.PrintWidth = 140 Chart.PrintHeight = 100 Chart.VisualEffect = True For n As Integer = 0 To 1 Series = Chart.SeriesList.Add() Series.Length = 10 For i As Integer = 0 To 9 Series.X(i) = i Series.Y(i) = i + n * 2 + Rand.Next(5) Next Next Dim txt As String = "可以利用Foxtable的ChartBuilder动态生成图表" Return txt Return Chart 2. httprequest代码: Dim fl As String = "d:\\web\\" & e.path If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar" e.WriteFile(fl) Return \'这里必须返回 End Select End If Select Case e.Path Case "test.htm" Dim wb As New WeUI Dim Chart As ChartBuilder = Functions.Execute("task") Dim txt As String = Functions.Execute("task") wb.AddPageTitle("","ph1",txt) wb.InsertHTML("<img width=\'100%\' src=\'" & wb.ImageToBase64(Chart.Image) & "\'/>") e.WriteString(wb.Build) End Select |
||
-- 作者:有点甜 -- 发布时间:2018/2/6 18:10:00 -- Dim Chart As New ChartBuilder
-------------------
Dim Chart As ChartBuilder = Functions.Execute("task")
Dim txt As String = chart.HeaderText
wb.AddPageTitle("","ph1",txt)
|