《VB》实验指导书讲解 下载本文

内容发布更新时间 : 2024/5/11 20:26:48星期一 下面是文章的全部内容请认真阅读。

Option Explicit Dim bPat As Byte

Private Sub Form_Load() bPat = 0 End Sub

Private Sub Form_Resize()

If Height < 6000 Then Height = 6000 If Width < 8000 Then Width = 8000

Picture1.Move 15, 585, Width - 160, Height - 1000 lblY.Move Picture1.Width / 2 + 20, 0

lblX.Move Picture1.Width - lblX.Width - 60, _ Picture1.Height / 2 - lblX.Height - 60

'当窗体发生改变时重画坐标、函数曲线 Picture1.Cls Pzb

If bPat Then Pechs End Sub

Private Sub cmdCls_Click() bPat = 0 Picture1.Cls Pzb End Sub

Private Sub cmdXsqx_Click() bPat = 1 Picture1.Cls Pzb Pechs End Sub

Private Sub Pechs() '画函数曲线

Dim x As Single, y As Single Dim px As Long, py As Long x = -100

Do Until x > 100 y = Hsz(x)

px = Picture1.Width - (Picture1.Width / 200) * (x + 100) py = Picture1.Height - (Picture1.Height / 200) * (y + 100) Picture1.PSet (px, py), RGB(0, 0, 255) x = x + 0.01 Loop End Sub

Private Sub Pzb() '画坐标

Dim lnDw As Long Picture1.Cls

Picture1.Line (0, Picture1.Height / 2) _

26

-(Picture1.Width, Picture1.Height / 2)

Picture1.Line (Picture1.Width / 2, 0) _ -(Picture1.Width / 2, Picture1.Height)

For lnDw = 0 To Picture1.Height _ Step Picture1.Height / 10

Picture1.Line (Picture1.Width / 2 - 30, lnDw) _ -(Picture1.Width / 2 + 30, lnDw) Next

For lnDw = 0 To Picture1.Width _ Step Picture1.Width / 10

Picture1.Line (lnDw, Picture1.Height / 2 - 30) _ -(lnDw, Picture1.Height / 2 + 30) Next End Sub

Private Function Hsz(x As Single) As Single

Hsz = Val(txtA) * x ^ 2 + Val(txtB) * x + Val(txtC) End Function 4.4思考题

1.制作工具栏有哪两种方法,有什么区别? 2.图像控件和图片框控件有什么区别?

27