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

在VB的类模块中使用定时器

    长久以来,由于不能直接获得VB类成员函数指针,因为无法在VB的类模块中直接使用定时器控件或定时器API,基于俺编写的获得类成员函数指针的函数,俺编写了这个带定时器功能的类,希望给朋友们一些启发。
    一、新建一个类,类名称为clsTimer,类代码如下:
Option Explicit
'* ******************************************** *
'* 模块名称:clsTimer.cls
'* 功能:在VB类模块中使用计时器
'* 作者:lyserver
'* ******************************************** *

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, ByVal Length As Long)
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Dim m_idTimer As Long
Dim m_Enabled As Boolean
Dim m_Interval As Long
Dim m_lTimerProc As Long

Private Sub Class_Initialize()
m_Interval = 0
m_lTimerProc = GetClassProcAddr(8)
End Sub

Private Sub Class_Terminate()
If m_idTimer <> 0 Then KillTimer 0, m_idTimer
End Sub

Public Property Get Interval() As Long
Interval = m_Interval
End Property
Public Property Let Interval(ByVal New_Value As Long)
If New_Value >= 0 Then m_Interval = New_Value
End Property

Public Property Get Enabled() As Boolean
Enabled = m_Enabled
End Property
Public Property Let Enabled(ByVal New_Value As Boolean)
m_Enabled = New_Value
If m_idTimer <> 0 Then KillTimer 0, m_idTimer
If New_Value And m_Interval > 0 Then
m_idTimer = SetTimer(0, 0, m_Interval, m_lTimerProc)
End If
End Property

Private Function GetClassProcAddr(ByVal Index As Long, Optional ParamCount As Long = 4, Optional HasReturnValue As Boolean) As Long
Static lR


相关文档:

获得VB listbox 选中项目(多项)的一个好方法

传统方法是遍历一遍
如果listbox 项目过多
明显速度不行
好方法是通过sendmessge发消息给listbox让他把选中项目直接传到参数数组中
You can use the SendMessage() API function instead.
As
you probably know, this function lets you send a message to one or more
windows. The declaration statement conforms ......

VB中filesystemobject对象实现文件存取方法

最简单的方法是使用filesystemobject对象。而它并非VB内置对象,
需引用才可以使用。
1.filesystemObject对象引用
“工程/引用/microsoft scription Runtime”
 在对象浏览器窗口中选“scripting”模块,看到增了许多对象,
drive filesystemobject    textstream &nbs ......

Developer Support Languages VC++, C# and VB.NET


Welcome to Microsoft Developer Support, Languages team blog! You will find a lot of language related troubleshooting resources here.
Troubleshooting PInvoke Related Issues 
I am back with some more PInvoke Stuff.  Recently I was working on a PInvoke issue which I found interesting ......

VB使用CopyMemory字符串处理

不能直接使用CopyMemoryStr,应该将字符串转为byte数组,然后使用CopyMemory
Property Get item() As String
    If h = 0 Then ErrRaise ERROR_INVALID_DATA
    'BugAssert p <> pNull
    Dim c As Long, ptr0 As Long
    Dim ab() As Byte
& ......

VB 操作Excel,附软件图

一、 VB读写EXCEL表:
  VB本身提自动化功能可以读写EXCEL表,其方法如下:
  1、在工程中引用Microsoft Excel类型库:
  从"工程"菜单中选择"引用"栏;选择Microsoft Excel 9.0 Object Library(EXCEL2000),然后选择"确定"。表示在工程中要引用EXCEL类型库。
  2、在通用对象 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号