求vb小实例
大家好,初次接触vb。学校要求期末的拿出像样的作品。但不知道vb具体可以做些什么,请大家给我一些小的应用实例,要适合初学者。感谢大家!
[解决办法]
VB简单看图程序:
Option Explicit
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
Const Srccopy = &HCC0020
Private Sub Command1_Click()
CommonDialog1.ShowOpen
bakPic.Picture = LoadPicture(CommonDialog1.FileName)
Dim wScale As Double
Dim hScale As Double
Dim newWidth As Double
Dim newHeight As Double
Dim newLeft As Double
Dim newTop As Double
wScale = Picture1.Width / bakPic.Width
hScale = Picture1.Height / bakPic.Height
If wScale > hScale Then
newWidth = bakPic.Width * hScale
newHeight = bakPic.Height * hScale
Else
newWidth = bakPic.Width * wScale
newHeight = bakPic.Height * wScale
End If
newLeft = (Picture1.Width - newWidth) / 2
newTop = (Picture1.Height - newHeight) / 2
Picture1.Cls
StretchBlt Picture1.hdc, newLeft, newTop, newWidth, newHeight, bakPic.hdc, 0, 0, bakPic.ScaleWidth, bakPic.ScaleHeight, Srccopy
Picture1.Refresh
End Sub
Private Sub Form_Load()
bakPic.AutoRedraw = True
bakPic.Visible = False
Me.ScaleMode = 3
Picture1.ScaleMode = 3
bakPic.ScaleMode = 3
End Sub