人人范文网 范文大全

VB程序设计说明(整理)

发布时间:2020-03-03 16:12:41 来源:范文大全 收藏本文 下载本文 手机版

选题介绍及意义,程序模块及功能,程序流程图,程序源码及注释,程序的后续完善及存在问题,设计程序的心得体会 一.选题说明及意义

用VB实现备忘录的基本功能,包括记事本,屏幕抓图,数字时钟和日历等功能,利用VB中的诸多控件,例如PictureBox,Label,CommendButton,Timer,CommendDialog,RichTextBox等,完成VB程序的诸多功能的实现,创建功能较为完善的记事本,并具有一定辅助功能,对于利用此软件的人能够具有一定的便利。 二.程序模块及功能实现流程图

三.部分程序代码 1.屏幕截图部分

Private Declare Function GetDC Lib \"user32\" (ByVal hwnd As Long) As Long Private Declare Function StretchBlt Lib \"gdi32\" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long,

1 ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Private Sub Command1_Click() Dim wScreen As Long Dim hScreen As Long Dim w As Long Dim h As Long Picture1.Cls wScreen = Screen.Width \\ Screen.TwipsPerPixelX hScreen = Screen.Height \\ Screen.TwipsPerPixelY ‘定义截屏的长度和宽度等于屏幕实际长宽 Picture1.ScaleMode = vbPixels w = Picture1.ScaleWidth h = Picture1.ScaleHeight hdcScreen = GetDC(0) r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy) ‘StretchBlt,函数名。该函数从源矩形中复制一个位图到目标矩形,必要时按目标设备设置的模式进行图像的拉伸或压缩。

End Sub

Private Sub Command2_Click() ‘另存为按键代码 Me.Picture = Me.Image CommonDialog1.Filter = \"BMP文件(*.bmp)|*.bmp|JPG文件(*.jpg)|*.jpg\" CommonDialog1.ShowSave CommonDialog1.Flags = &H2 + &H4 + &H8 ‘&H2使用长文件名

2 &H4 隐藏只读复选框。

&H8强制对话框将对话框打开时的目录置成当前目录

If CommonDialog1.FileName \"\" Then SavePicture Me.Picture, CommonDialog1.FileName End If End Sub

Private Sub Command3_Click() ‘退出按键代码 Form3.Hide form6.Show End Sub 2.登陆部分

Option Explicit Dim Npa As Integer

Private Sub Command1_Click() If username.Text = \"111\" And paword.Text = \"111\" And Npa

3 paword.SetFocus End If End If End Sub

Private Sub Command2_Click() username.Text = \"\" paword.Text = \"\" End Sub 3.日记本部分代码

Dim sfind As String Dim FileType, FiType As String Private Sub copy_Click() ‘复制按键 Clipboard.Clear On Error Resume Next Clipboard.SetText TxtDemo.SelText End Sub

Private Sub date_Click() ‘日期按键 Text1.SelText = Now End Sub

Private Sub delete_Click() ‘删除按键 RichTextBox1.SelText = \"\" End Sub

Private Sub edits_Click() ‘编辑按键 RichTextBox1.SetFocus End Sub

4

Private Sub exit_Click() ‘退出按键 Form2.Hide Form1.Show End Sub

Private Sub find_Click() ‘查找按键 Dim sfind As Integer sfind = InputBox(\"请输入要查找的词:\", \"查找内容\", sfind) RichTextBox1.find sfind If RichTextBox1.SelText sfind Then MsgBox \"找不到要查询的内容\", , \"查询结果报告\" End If End Sub Private Sub Form_Load() Me.Height = 6000 Me.Width = 9000

On Error Resume Next \'出错处理 RichTextBox1.Top = 20 RichTextBox1.Left = 20 RichTextBox1.Height = ScaleHeight40 End Sub

Private Sub new_Click(Index As Integer) ‘新建按键 RichTextBox1.Text = \"\" \'清空文本框

5 FileName = \"未命名\" Me.Caption = FileName End Sub

Private Sub open_Click() ‘打开部分

CommonDialog1.Filter = \"文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*\" CommonDialog1.ShowOpen RichTextBox1.Text = \"\" \'清空文本框 FileName = CommonDialog1.FileName RichTextBox1.LoadFile FileName Me.Caption = \"记事本:\" & FileName End Sub

Private Sub paste_Click() Clipboard.Clear On Error Resume Next Clipboard.SetText RichTextBox1.SelText RichTextBox1.SelText = \"\" End Sub

Private Sub riji_Click() ‘帮助日记部分 MsgBox \"日记Ver1.0版权所有(C)网络\", vbOKOnly, \"关于\"

End Sub

Private Sub save_Click() ‘保存文件部分

6 CommonDialog1.Filter = \"文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*\" CommonDialog1.ShowSave FileType = CommonDialog1.FileTitle FiType = LCase(Right(FileType, 3)) FileName = CommonDialog1.FileName Select Case FiType Case \"txt\" RichTextBox1.SaveFile FileName, rtfText Case \"rtf\" RichTextBox1.SaveFile FileName, rtfRTF Case \"*.*\" RichTextBox1.SaveFile FileName End Select Me.Caption = \"记事本:\" & FileName End Sub

Private Sub selectall_Click() ‘全选部分 RichTextBox1.SelStart = 0 RichTextBox1.SelLength = Len(RichTextBox1.Text) End Sub

Private Sub tie_Click() ‘剪切部分 On Error Resume Next RichTextBox1.SelText = Clipboard.GetText RichTextBox1.SelText = \"\"

7 End Sub 4.数字时钟部分代码

Private LastMinute As Integer Private LastHour As Integer Private Lastx As Integer Private Lasty As Integer

Private Sub Form_Load() Lastx = 999 End Sub

Private Sub Timer1_Timer() Const pi = 3.141592653 ‘定义圆周率 Dim T Dim X As Integer Dim Y As Integer T = Now SEC = Second(T) Min = Minute(T) HR = Hour(T) frmClock.Scale (-16, 16)-(16, -16) If Min lastMin Or HR LastHour Then LastMinute = Min LastHour = HR frmClock.Cls Lastx = 999 frmClock.DrawWidth = 2 frmClock.DrawMode = 13

8 h = HR + pi / 60 X = 5 * Sin(h * pi / 6) Y = 5 * Cos(h * pi / 6) frmClock.Line (0, 0)-(X, Y) X = 8 * Sin(Min * pi / 30) Y = 8 * Cos(Min * pi / 30) frmClock.Line (0, 0)-(X, Y) frmClock.DrawWidth = 1 End If frmClock.DrawMode = 10 RED = RGB(255, 0, 0) X = 10 * Sin(SEC * pi / 30) Y = 10 * Cos(SEC * pi / 30) If Lastx 999 Then frmClock.Line (0, 0)-(Lastx, Lasty), RED End If frmClock.Line (0, 0)-(X, Y), RED Lastx = X Lasty = Y End Sub

Private Sub NoUse_Click() Unload Me End Sub 四.程序后续完善及存在问题

目前程序功能较为简单,对于备忘录部分只能实现简单的文字输入和截屏,日历,数字时钟的功能,在以后陆续的开发中会实现更多更复杂的功能,例如定时提醒,连接数据库,Excel表格等功能,程序在设计之初与最后成品稍有

9 不同,对于程序设计中部分功能未能实现,十分遗憾,在以后的学习中会加强程序设计部分知识,逐渐完善程序功能。 五.设计程序的心得体会

通过此次程序设计,我对于VB程序语言和VB各类控件有了更深入的了解,对于综合VB各项函数等也有了更深入的学习,完成一个综合的作品对于学习编程语言来说是进阶必不可少的一部分,通过完成自己的作品也激发了我的创造思维和创作能力。在以后的学习中,我也会继续学习和深入了解编程语言,为更好的做学术研究打基础。

10

论文VB程序

vb成绩判断程序

学生成绩管理系统VB程序

八年级下册VB程序教学设计

vb

VB程序连乘算法的教学设计

《我的第一个VB程序》教学设计

VB说课稿

VB时钟

VB题库

VB程序设计说明(整理)
《VB程序设计说明(整理).doc》
将本文的Word文档下载到电脑,方便编辑。
推荐度:
点击下载文档
点击下载本文文档