VB程序设计说明Word文档格式.docx
《VB程序设计说明Word文档格式.docx》由会员分享,可在线阅读,更多相关《VB程序设计说明Word文档格式.docx(8页珍藏版)》请在冰豆网上搜索。
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,函数名。
该函数从源矩形中复制一个位图到目标矩形,必要时按目标设备设置的模式进行图像的拉伸或压缩。
EndSub
PrivateSubCommand2_Click()‘另存为按键代码
Me.Picture=Me.Image
CommonDialog1.Filter="
BMP文件(*.bmp)|*.bmp|JPG文件(*.jpg)|*.jpg"
CommonDialog1.ShowSave
CommonDialog1.Flags=&
H2+&
H4+&
H8
‘&
H2使用长文件名
&
H4隐藏只读复选框。
H8强制对话框将对话框打开时的目录置成当前目录
IfCommonDialog1.FileName<
>
"
"
Then
SavePictureMe.Picture,CommonDialog1.FileName
EndIf
PrivateSubCommand3_Click()‘退出按键代码
Form3.Hide
form6.Show
2.登陆部分
OptionExplicit
DimNpassAsInteger
Ifusername.Text="
111"
Andpassword.Text="
AndNpass<
3Then
Form5.Hide
Form2.Show
Else
Npass=Npass+1
IfNpass=3Then
MsgBox"
你没有机会了"
End
密码第"
&
Npass&
错误!
请再试一次."
0,"
密码输入错误"
password.Text="
'
password.SetFocus
PrivateSubCommand2_Click()
username.Text="
password.Text="
3.日记本部分代码
DimsfindAsString
DimFileType,FiTypeAsString
PrivateSubcopy_Click()‘复制按键
Clipboard.Clear
OnErrorResumeNext
Clipboard.SetTextTxtDemo.SelText
PrivateSubdate_Click()‘日期按键
Text1.SelText=Now
PrivateSubdelete_Click()‘删除按键
RichTextBox1.SelText="
PrivateSubedits_Click()‘编辑按键
RichTextBox1.SetFocus
PrivateSubexit_Click()‘退出按键
Form2.Hide
Form1.Show
PrivateSubfind_Click()‘查找按键
DimsfindAsInteger
sfind=InputBox("
请输入要查找的词:
"
查找内容"
sfind)
RichTextBox1.findsfind
IfRichTextBox1.SelText<
sfindThen
MsgBox"
找不到要查询的内容"
,"
查询结果报告"
EndIf
PrivateSubForm_Load()
Me.Height=6000
Me.Width=9000
OnErrorResumeNext'
出错处理
RichTextBox1.Top=20
RichTextBox1.Left=20
RichTextBox1.Height=ScaleHeight-40
RichTextBox1.Width=ScaleWidth-40
PrivateSubnew_Click(IndexAsInteger)‘新建按键
RichTextBox1.Text="
清空文本框
FileName="
未命名"
Me.Caption=FileName
PrivateSubopen_Click()‘打开部分
CommonDialog1.Filter="
文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
FileName=CommonDialog1.FileName
RichTextBox1.LoadFileFileName
Me.Caption="
记事本:
FileName
PrivateSubpaste_Click()
Clipboard.SetTextRichTextBox1.SelText
RichTextBox1.SelText="
PrivateSubriji_Click()‘帮助日记部分
日记Ver1.0版权所有(C)网络"
vbOKOnly,"
关于"
PrivateSubsave_Click()‘保存文件部分
CommonDialog1.ShowSave
FileType=CommonDialog1.FileTitle
FiType=LCase(Right(FileType,3))
SelectCaseFiType
Case"
txt"
RichTextBox1.SaveFileFileName,rtfText
Case"
rtf"
RichTextBox1.SaveFileFileName,rtfRTF
*.*"
RichTextBox1.SaveFileFileName
EndSelect
PrivateSubselectall_Click()‘全选部分
RichTextBox1.SelStart=0
RichTextBox1.SelLength=Len(RichTextBox1.Text)
PrivateSubtie_Click()‘剪切部分
OnErrorResumeNext
RichTextBox1.SelText=Clipboard.GetText
4.数字时钟部分代码
PrivateLastMinuteAsInteger
PrivateLastHourAsInteger
PrivateLastxAsInteger
PrivateLastyAsInteger
Lastx=999
PrivateSubTimer1_Timer()
Constpi=3.141592653‘定义圆周率
DimT
DimXAsInteger
DimYAsInteger
T=Now
SEC=Second(T)
Min=Minute(T)
HR=Hour(T)
frmClock.Scale(-16,16)-(16,-16)
IfMin<
lastMinOrHR<
LastHourThen
LastMinute=Min
LastHour=HR
frmClock.Cls
frmClock.DrawWidth=2
frmClock.DrawMode=13
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.DrawWidth=1