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

获得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 to the following syntax:
Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg _
   As Long, ByVal wParam As Long, lParam As Any) As Long
Since
we want to gather the listbox: selected items, we'll send the
LB_GETSELITEMS constant in the wMsg argument, which you declare like so:
Private Const LB_GETSELITEMS = &H191
The LB_GETSELITEMS message fills an array with the index numbers of all the selected items.
Dim ItemIndexes() As Long, x As Integer, iNumItems As Integer
iNumItems = ThisBox.SelCount
If iNumItems Then
   ReDim ItemIndexes(iNumItems - 1)
   SendMessage ListBox1.hwnd, LB_GETSELITEMS, iNumItems, ItemIndexes(0)
End If
For x = 0 To iNumItems - 1
   MsgBox ListBox1.List(ItemIndexes(x)) '弹出对话框
Next x
After
being passed to the SendMessage function, iNumItems holds the total
number of selected items, and the ItemIndexes array holds the selected
item index values. Notice, that you must pass a pointer to the
ItemIndexes array, and not the array itself. Thus, we passed
ItemIndexes(0) into the SendMessage function, not ItemIndexes().


相关文档:

VB中播放WAV文件

http://zhidao.baidu.com/question/33440250.html
在模块中输入以下代码
Public Declare Function sndPlaySound Lib "winmm" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
' flag uitzetten
Public Const SND_SYNC = &H0
Public Const SND_ASYNC = &H1 ......

VB中利用DataBase巧妙设置DataReport中的动态SQL

    近日分析一VB做的报表,由于对VB只是了解,谈不上熟练,不过对其水晶报表倒有点认识,之前也做过三两个小的报表 ,加之对PB中的报表了解非常熟悉,当时信心蛮大的。
    先是看了DataReport,用于绘制报表格式。再来看DataEnvironment,用于定义获取的数据列。将DataReport与DataEnviro ......

VB调整Excel格式

Private Sub Cmd_OK_Click()
    Dim ExcelAppX As Excel.Application
    Dim ExcelBookX As Excel.Workbook
    Dim ExcelSheetX As Excel.Worksheet
   
    Dim a(1 To 3) As Single
    Dim strFormat As Variant ......

[VB]获取SYSKEY

很久以前的一个代码了。。。。。那时还沉迷于研究WindowsXP登录密码的计算方法。。。。
先新建一个VB工程,画一个CommandButton,改名为cmdGetSYSKEY,画一个TextBox,改名为txtSYSKEY,然后粘贴下面的代码,运行即可,在WindowsXP SP2 Build 2600 + VB6.0 SP6下测试通过,获得的SYSKEY与Cain&Abel v4.9.6一致。。。。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号