以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何在功能区实现天气实况+插入图片+当前时间 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=162397) |
||||
-- 作者:lhfu -- 发布时间:2021/4/13 14:22:00 -- [求助]如何在功能区实现天气实况+插入图片+当前时间 各位老师,我在想功能区实现这三样场景,但我考了论坛相关帮助后,代码如下: 功能区插入图片: Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.picturebox a.BackgroundImage = getimage("D:\\用户目录\\Desktop\\管理项目1\\管理项目1\\Images\\001.png") a.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 300 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组2").Items.Insert(0,b) ------------------------------------------------------------------------------------------ 天气预报: Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.WebBrowser a.Navigate("http://i.tianqi.com/index.php?c=code&id=12&icon=1&num=5&site=12") Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 800 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组2").Items.add(b) ----------------------------------------------------------------- 当前时间显示: RibbonTabs("功能区1").Groups("功能组3").Items("标签1").text = "今天是:" & format(Date.now, "G") 但把以上三段代码输入,它是提示变量错误的,请各位老师指导一下,谢谢! |
||||
-- 作者:有点蓝 -- 发布时间:2021/4/13 14:23:00 -- a这个变量名称重复了,换个不同的名称使用 |
||||
-- 作者:lhfu -- 发布时间:2021/4/13 15:00:00 -- 蓝老师,我这是修改,好像变量也是行不能的,能指导一下我吗? 功能区插入图片 Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.picturebox a.BackgroundImage = getimage("D:\\用户目录\\Desktop\\管理项目1\\管理项目1\\Images\\001.png")\'图片目录 a.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 300 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组2").Items.Insert(0,b)\'须在菜单项目增加对应组 天气预报 Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.WebBrowser a.Navigate("http://i.tianqi.com/index.php?c=code&id=12&icon=1&num=5&site=12") Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 800 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组3").Items.add(b)
[此贴子已经被作者于2021/4/13 15:01:03编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/4/13 15:09:00 -- 提示很明显了,变量名称重复,换个不同的名称不行吗?!http://www.foxtable.com/webhelp/topics/0209.htm 建议花时间重新过一过编程基础
|
||||
-- 作者:lhfu -- 发布时间:2021/4/13 16:03:00 -- RibbonTabs("功能区1").Groups("功能组3").Items("标签2").text = "今天是:" & format(Date.now, "G") Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.picturebox a.BackgroundImage = getimage("D:\\用户目录\\Desktop\\管理项目1\\管理项目1\\Images\\001.png")\'图片目录 a.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 300 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组2").Items.Insert(0,b)\'须在菜单项目增加对应组 Dim C2Ribbon1 As C2Ribbon.C2Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.WebBrowser a.Navigate("http://i.tianqi.com/index.php?c=code&id=12&icon=1&num=5&site=12") Dim b As New C2Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 800 b.height = 120 C2Ribbon1.tabs("功能区1").Groups("功能组4").Items.add(b) 但我这样改了变量名后, 它也这样提示类型,我有点搞不定啊,请蓝老师指教一下呀
|
||||
-- 作者:有点蓝 -- 发布时间:2021/4/13 16:27:00 -- 在多看几遍:http://www.foxtable.com/webhelp/topics/0209.htm,理解一下哪个是变量,哪个是数据类型,改变量,不要改数据类型 |
||||
-- 作者:lhfu -- 发布时间:2021/4/13 16:45:00 -- 唉,实际磨不透这段代码应该怎么写,应该我改不变量,其它又报错了,请蓝老师指导一下,谢谢 |
||||
-- 作者:有点蓝 -- 发布时间:2021/4/13 16:47:00 -- 先告诉我下面代码哪个是变量,哪个是数据类型? Dim C1Ribbon1 As C1Ribbon.C1Ribbon -------------- 声明变量的语法是: Dim 变量名 As 数据类型 例如: Dim Name As String 表示声明了一个新的String(字符串)型变量,变量名为“Name”。 |
||||
-- 作者:有点蓝 -- 发布时间:2021/4/13 16:50:00 -- 在同一段代码中不能重复定义同一个名称的变量,下面用法是错误的 Dim C1Ribbon1 As C1Ribbon.C1Ribbon Dim C1Ribbon1 As C1Ribbon.C1Ribbon 改为不同的名称即可 Dim C1Ribbon1 As C1Ribbon.C1Ribbon Dim C1Ribbon2 As C1Ribbon.C1Ribbon Dim C1Ribbon3 As C1Ribbon.C1Ribbon
|
||||
-- 作者:lhfu -- 发布时间:2021/4/13 17:27:00 -- 蓝老师,我稍为改动一下,第二段天气预报不会显示出来,我是哪里改错了吗? Dim C1Ribbon1 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim a As New system.Windows.Forms.picturebox a.BackgroundImage = getimage("D:\\用户目录\\Desktop\\管理项目1\\管理项目1\\Images\\001.png") a.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch Dim b As New C1Ribbon.RibbonControlHost(a) b.name = "自定义项1" b.width = 300 b.height = 120 C1Ribbon1.tabs("功能区1").Groups("功能组2").Items.Insert(0,b) Dim C1Ribbon2 As C1Ribbon.C1Ribbon = Ctype(BaseMainForm.controls("C1Ribbon1"),C1Ribbon.C1Ribbon ) Dim d As New system.Windows.Forms.WebBrowser d.Navigate("http://i.tianqi.com/index.php?c=code&id=12&icon=1&num=5&site=12") Dim c As New C1Ribbon.RibbonControlHost(a) c.name = "自定义项2" c.width = 300 c.height = 120 C1Ribbon2 .tabs("功能区1").Groups("功能组4").Items.add(c) 重启软件后,打开是这样子的 是不是第二段天气代码我改错哪里了呢,请指正一下,谢谢.
|