vb使用picturebox画曲线图
'添加个picture1和command1
Option Explicit
Dim lngCenter As Long
Dim lngMax As Long
Dim lngPad&
Dim PCurrent As POINT, PLast As POINT
Private Type POINT
x As Long
y As Long
End Type
Private Sub Form_Load()
lngCenter = (Picture1.Top + Picture1.Height) / 2
lngMax = Picture1.Height
PLast.x = 0
PLast.y = lngCenter
Dim i&
For i = 0 To Picture1.Width Step 100
Picture1.Line (i, 0)-(i, Picture1.Height), &HFFC0C0
Next
For i = 0 To Picture1.Height Step 100
Picture1.Line (0, i)-(Picture1.Width, i), &HFFC0C0
Next
Picture1.DrawWidth = 1.5
Picture1.Line (0, lngCenter)-(Picture1.Width, lngCenter), vbBlue
Picture1.DrawWidth = 1
End Sub
Private Sub Timer1_Timer()
PCurrent.x = PCurrent.x + 50
Randomize
PCurrent.y = Rnd * lngMax
Picture1.Line (PCurrent.x, PCurrent.y)-(PLast.x, PLast.y), vbRed
PLast.x = PCurrent.x
PLast.y = PCurrent.y
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
效果图:
如果需要带有点规律性可以将获得y的坐标稍加处理下:
Private Function getRndY() As Integer
Dim lngTmp%
If intRnd = 0 Then
Randomize
intRnd = Rnd * 3 + 1
End If
Randomize
lngTmp = Rnd * lngCenter
If PLast.y > lngCenter Then
getRndY = lngCenter + lngTmp
Else
getRndY = lngTmp
End If
intCurRnd = intCurRnd + 1
If intCurRnd > intRnd Then
Randomize
intRnd = Rnd * 3 + 1
&nb
相关文档:
Option Explicit
Dim FSO As New FileSystemObject
Dim currentFolder As Folder
Dim currentFolderName As String
Dim folderItem, fileItem
Private Sub Form_Load()
currentFolderName = FSO.GetFolder(App.Path) & "\content"
SeachFolder (FSO.GetFolder(currentFolderName))
End Sub ......
珍贵vb函数列表
Variant 变量的内部表示:
_______________________________________________________________
符号常量 值 内部表示 字节数
V_EMPTY 0 Empty
V_NULL 1 Null
V_INTEGER 2 Interger 2
V_LONG 3 Long 4
V_SINGLE 4 Single 4
V_DOUBLE 5 Double 8
V_CURRENCY 6 Currency 8
V_DATE 7 Date 8
V_STRI ......
今天在公司服务器上看一个老掉牙的asp程序,发现竟然调用了自定义com组件,是vb写的,封装了数据库连接与操作,文档上写这样做是为什么用户到服务器也看不到数据库的用户名与密码,也对啊,这个是财务的服务器,当然不能让我们it随便看了,呵呵!(it忽悠finance,让finance相信it看不到数据库用户名与密码,my god)由于, ......
Private Sub Command12_Click()
Dim i As Integer
On Error GoTo ABC
ShowPrinterSetup Me
For i = 1 To Adodc1.Recordset.RecordCount
If Picture2.Picture <> LoadPicture("") Then
Printer.PaintPicture Picture2.Picture, 200, Picture1.Top + 1000
Else
......
VB数据库操作实例
2008-02-22 05:49
VB数据库操作对很多初学者朋友感到比较吃力,目前教材中的实例对数据库操作都比较单一,很多朋友提议我做一个包括浏览、添加、修改、删除功能的数据库操作实例,下面这个实例就是一个这样的数据库操作实例。
《书库管理系统》是一个最简单的数据库操作实例 ......