VB程序设计说明

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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

一.选题说明及意义

用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,

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使用长文件名

&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 Npass As Integer

Private Sub Command1_Click()

If username.Text = "111" And password.Text = "111" And Npass < 3 Then Form5.Hide

Form2.Show

Else

Npass = Npass + 1

If Npass = 3 Then

MsgBox "你没有机会了"

End

Else

MsgBox "密码第" & Npass & "错误! 请再试一次.", 0, "密码输入错误"

password.Text = "" '

password.SetFocus

End If

End If

End Sub

Private Sub Command2_Click()

username.Text = ""

password.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

相关文档
最新文档