Visual Basic课程设计.doc_第1页
Visual Basic课程设计.doc_第2页
Visual Basic课程设计.doc_第3页
Visual Basic课程设计.doc_第4页
Visual Basic课程设计.doc_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Visual Basic课程设计说明书题 目: vb课程设计 姓 名: 陈琳 学 号: 100105201 指导教师: 肖猛 综合成绩: 2011年11月VB课程设计报告滚动版字幕一、设计目的在生活中有许多需要滚动字幕的,人们在公共场所经常见到的用来显示消息、广告、通知等内容的显示屏。滚动字幕的方式容易引起观众注意,具有良好的宣传作用。本程序要求编制一个模拟滚动字幕板的实用程序。二、程序功能介绍(1)启动程序,同时显示图1、图2所示的2个参考界面,窗口1用来显示滚动字幕的显示板,窗口2是控制板。图1 显示窗口图2 控制窗口(2)单击控制窗口中的“开始滚动”按钮,显示窗口中的文字开始滚动显示。滚动的方式由控制窗口中的“字幕滚动方向控制”框中的4个单选框决定。“滚动字幕的文字大小控制”框可以控制字体大小。“滚动字幕字体控制”是4个按钮式样的单选框,用于设置字体样式。(3)本程序提供8中内置文字内容,单击“内置文字”框中的任一个按钮可以改变字幕的内容。如果要显示自定义的文字内容,可以直接在底部文本框中输入,然后回车即可。(4)通过“前景色”和“背景色”组合框(图3所示),可以改变滚动字幕的前景色和背景色。若选择“颜色自动变化”复选框,则滚动字幕的前景色和背景色均自动变化(每1s变化一次)。图3 选择颜色三、程序分析Dim lz(0 To 7) As String 定义数组lz,用于保存内置字幕Private Sub Check1_Click() 复选框“颜色自动变化”点击事件If Check1.Value = 1 Then 如果check1被选中(值为1)Form2.Timer5.Enabled = True timer5开始工作ElseIf Check1.Value = 0 Then 如果check1未被选中(值为0)Form2.Timer5.Enabled = False timer5停止工作End IfEnd SubPrivate Sub Combo1_Click() 前景色选项combo1点击事件If Combo1.Text = 黑色 ThenForm2.Label1.ForeColor = vbBlack 滚动字幕文字颜色变为黑色,下同ElseIf Combo1.Text = 绿色 ThenForm2.Label1.ForeColor = vbGreenElseIf Combo1.Text = 蓝色 ThenForm2.Label1.ForeColor = vbBlueElseIf Combo1.Text = 青色 ThenForm2.Label1.ForeColor = vbCyanElseIf Combo1.Text = 红色 ThenForm2.Label1.ForeColor = vbRedElseIf Combo1.Text = 黄色 ThenForm2.Label1.ForeColor = vbYellowElseIf Combo1.Text = 紫色 ThenForm2.Label1.ForeColor = QBColor(9) + QBColor(4)End IfEnd SubPrivate Sub Combo2_Click() 背景色选项combo2点击事件If Combo2.Text = 黑色 ThenForm2.BackColor = vbBlack 滚动字幕窗口背景改为黑色,下同Form2.Label1.BackColor = vbBlack 滚动字幕标签控件背景色改为黑色,下同ElseIf Combo2.Text = 绿色 ThenForm2.BackColor = vbGreenForm2.Label1.BackColor = vbGreenElseIf Combo2.Text = 蓝色 ThenForm2.BackColor = vbBlueForm2.Label1.BackColor = vbBlueElseIf Combo2.Text = 青色 ThenForm2.BackColor = vbCyanForm2.Label1.BackColor = vbCyanElseIf Combo2.Text = 红色 ThenForm2.BackColor = vbRedForm2.Label1.BackColor = vbRedElseIf Combo2.Text = 黄色 ThenForm2.BackColor = vbYellowForm2.Label1.BackColor = vbYellowElseIf Combo2.Text = 紫色 ThenForm2.BackColor = QBColor(9) + QBColor(4)Form2.Label1.BackColor = QBColor(9) + QBColor(4)End IfEnd SubPrivate Sub Command1_Click(Index As Integer) command按钮点击事件(command1控件数组)Select Case Index 调用select caseCase 0 index值为0的按钮(内置字幕按钮“1”)被点击,下同Form2.Label1.Caption = Command1(0).ToolTipText 滚动字幕变为Command1(0)的tooltiptext,下同Case 1Form2.Label1.Caption = Command1(1).ToolTipTextCase 2Form2.Label1.Caption = Command1(2).ToolTipTextCase 3Form2.Label1.Caption = Command1(3).ToolTipTextCase 4Form2.Label1.Caption = Command1(4).ToolTipTextCase 5Form2.Label1.Caption = Command1(5).ToolTipTextCase 6Form2.Label1.Caption = Command1(6).ToolTipTextCase 7Form2.Label1.Caption = Command1(7).ToolTipTextCase 8 index值为8的按钮(“恢复设置”按钮)被点击Form2.Label1.Caption = 欲穷千里目,更上一层楼 初始化Form2.Label1.FontSize = 25Form2.Label1.ForeColor = &H80000012Form2.BackColor = &H8000000FForm2.Label1.BackColor = &H8000000FCombo1.Text = 未选择Combo2.Text = 未选择Command1(9).Caption = 开始滚动For i = 0 To 9 初始化option控件数组Option1(i).Value = FalseNext iForm2.Timer1.Enabled = False timer1关闭状态,下同Form2.Timer2.Enabled = FalseForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = FalseForm2.Timer5.Enabled = FalseCheck1.Value = 0HScroll1.Value = 1Form2.Timer1.Interval = 1 设置timer1的interval属性,下同Form2.Timer2.Interval = 1Form2.Timer3.Interval = 1Form2.Timer4.Interval = 1Form2.Timer5.Interval = 1000Form2.Label1.Left = 0 初始化完毕Case 9 index属性为9的按钮(“开始滚动”按钮)背点击If Command1(9).Caption = 停止 ThenForm2.Timer1.Enabled = FalseForm2.Timer2.Enabled = FalseForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = FalseForm2.Timer5.Enabled = FalseCommand1(9).Caption = 继续ElseIf Option1(6).Value = False And Option1(7).Value = False And Option1(8).Value = False And Option1(9).Value = False ThenForm2.Timer2.Enabled = True timer2开始工作,下同ElseIf Option1(6).Value = True ThenForm2.Timer1.Enabled = TrueElseIf Option1(7).Value = True ThenForm2.Timer3.Enabled = TrueElseIf Option1(8).Value = True ThenForm2.Timer2.Enabled = TrueElseIf Option1(9).Value = True ThenForm2.Timer4.Enabled = TrueEnd IfCommand1(9).Caption = 停止End IfCase 10 index属性为10的按钮(“退出”按钮)被点击EndEnd SelectEnd SubPrivate Sub Command2_Click() “隐藏控制面板”按钮点击事件Form1.Hide End SubPrivate Sub Command3_Click() “自定义内置字幕”按钮点击事件Form3.ShowEnd SubPrivate Sub Form_Load() 窗口加载事件Combo1.Text = 未选择Combo2.Text = 未选择Form2.ShowForm2.Label1.Caption = 欲穷千里目,更上一层楼Form2.Label1.FontSize = 25 滚动字幕文字大小设为25Open lz.dat For Input As #1 读取当前目录下的lz.dat文件(文件编号#1)For i = 0 To 7 循环读取 Input #1, lz(i) 读取的数据存入lz数组中Command1(i).ToolTipText = lz(i)NextClose #1 关闭文件#1Form2.Timer1.Interval = 1Form2.Timer2.Interval = 1Form2.Timer3.Interval = 1Form2.Timer4.Interval = 1Form2.Timer5.Interval = 1000Form2.Timer1.Enabled = FalseForm2.Timer2.Enabled = FalseForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = FalseForm2.Timer5.Enabled = FalseText1.Text = 在此输入字幕内容并回车HScroll1.Min = 1: HScroll1.Max = 100 设置水平滚动条的最小值以及最大值End SubPrivate Sub Form_Unload(Cancel As Integer) form1窗口卸载事件EndEnd SubPrivate Sub HScroll1_Change() 水平滚动条改变事件If Form2.Timer1.Enabled = True ThenForm2.Timer1.Interval = HScroll1.Value 改变timer1的interval属性值,下同ElseIf Form2.Timer2.Enabled = True ThenForm2.Timer2.Interval = HScroll1.ValueElseIf Form2.Timer3.Enabled = True ThenForm2.Timer3.Interval = HScroll1.ValueElseIf Form2.Timer4.Enabled = True ThenForm2.Timer4.Interval = HScroll1.ValueEnd IfEnd SubPrivate Sub Option1_Click(Index As Integer) option单选框点击事件(option1控件数组)Select Case Index 调用select caseCase 0 index属性为0的单选框(“大字体”单选框)点击事件。,下同Form2.Label1.FontSize = 25Case 1Form2.Label1.FontSize = 15Case 2Form2.Label1.FontName = 宋体 改变滚动字幕的字体为“宋体”,下同Case 3Form2.Label1.FontName = 仿宋_gb2312Case 4Form2.Label1.FontName = 楷体_gb2312Case 5Form2.Label1.FontName = 黑体Case 6Form2.Timer1.Enabled = TrueForm2.Timer2.Enabled = FalseForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = FalseCommand1(9).Caption = 停止Case 7Form2.Timer1.Enabled = FalseForm2.Timer2.Enabled = FalseForm2.Timer3.Enabled = TrueForm2.Timer4.Enabled = FalseCommand1(9).Caption = 停止Case 8Form2.Timer1.Enabled = FalseForm2.Timer2.Enabled = TrueForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = FalseCommand1(9).Caption = 停止Case 9Form2.Timer1.Enabled = FalseForm2.Timer2.Enabled = FalseForm2.Timer3.Enabled = FalseForm2.Timer4.Enabled = TrueCommand1(9).Caption = 停止End SelectEnd SubPrivate Sub Text1_GotFocus() text1获得焦点事件Text1.Text = End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) text1的keypress(按键盘)事件If Text1.Text Then 如果text1不为空If KeyAscii = 13 Then 如果按下“enter”键Form2.Label1.Caption = Text1.Text 将滚动字幕内容变为text1的内容End IfEnd IfEnd SubPrivate Sub Text1_LostFocus() text1丢失焦点事件Text1.Text = 在此输入字幕内容并回车End SubForm2(滚动字幕面板)代码如下:Dim cor(6) As String 定义cor数组,存储颜色选项Option ExplicitDim fx As IntegerPrivate Sub Form_DblClick() form2的双击鼠标事件Form1.ShowEnd SubPrivate Sub Form_Load() form2的加载事件fx = 1Label1.AutoSize = TrueForm2.Width = Form1.WidthLabel1.FontSize = 25cor(0) = vbBlack: cor(1) = vbGreen: cor(2) = vbBlue: cor(3) = vbCyan: cor(4) = vbRed: cor(5) = vbYellow: cor(6) = QBColor(9) + QBColor(4) 给cor数组的元素分别赋值End SubPrivate Sub Label1_DblClick() 滚动字幕标签双击鼠标事件Form1.ShowEnd SubPrivate Sub Timer1_Timer() timer1控制“从左往右”Label1.Left = Label1.Left + 15If Label1.Left Form2.Width ThenLabel1.Left = -Label1.WidthEnd IfEnd SubPrivate Sub Timer2_Timer() timer2控制从右往左Label1.Left = Label1.Left - 15If Label1.Left -Label1.Width ThenLabel1.Left = Label1.Left - 15Elsefx = 0End IfElseIf Label1.Left 0 ThenLabel1.Left = Label1.Left - 15Elsefx = 0End IfElseIf Label1.Left (Form2.Width - Label1.Width) ThenLabel1.Left = Label1.Left + 15Elsefx = 1End IfEnd IfEnd SubPrivate Sub Timer5_Timer() timer5控制颜色自动变化RandomizeDim a As Integer, b As Integera = Int(7 * Rnd)b = Int(7 * Rnd)If a b ThenForm2.BackColor = cor(a)Label1.BackColor = cor(a)Label1.ForeColor = cor(b)ElseIf a = 6 ThenForm2.BackColor = cor(a)Label1.BackColor = cor(a)Label1.ForeColor = cor(b - 1)ElseForm2.BackColor = cor(a)Label1.BackColor = cor(a)Label1.ForeColor = cor(b + 1)End IfEnd IfEnd SubForm3(自定义内置字幕)代码如下:Dim zm(0 To 7) As String 定义数组zm,存储自定义内置字幕Private Sub Command1_Click() “保存修改”按钮点击事件F

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论