易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

VB遍历当前目录

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 中颜色互相转换的两个小函数(REG和 VB颜)

VB颜色和RGB色互相转换头疼了我好一段时间,如今找到解决办法了
特别贴出来与大家共享 
Type RGB
    Red As String
    Green As String
    Blue As String
End Type
Public Function ColorToRGB(ByVal dwColor As Long) As RGB
    Dim clrHex ......

VB/C++/C#串口通讯源代码【附详细注释】


VB
    If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
    MSComm1.CommPort = i1
    MSComm1.PortOpen = True
    MSComm1.InputMode = comInputModeBinary
    MSComm1.InBufferCount = 0
& ......

vb批量打印数据库中的照片

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调用系统的"打印机设置"和"页面设置".

VB调用系统的"打印机设置"和"页面设置".
Option Explicit
Const FW_NORMAL = 400
Const DEFAULT_CHARSET = 1
Const OUT_DEFAULT_PRECIS = 0
Const CLIP_DEFAULT_PRECIS = 0
Const DEFAULT_QUALITY = 0
Const DEFAULT_PITCH = 0
Const FF_ROMAN = 16
Const CF_PRINTERFONTS = &H2
Const C ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号