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
Function SeachFolder(str As String)
Dim itemFolder
Dim curFolder As Folder
Set curFolder = FSO.GetFolder(str)
Dim itemFile
For Each itemFolder In curFolder.SubFolders
SeachFolder (CStr(itemFolder))
Me.Text1.Text = Me.Text1.Text & itemFolder & Chr(13) & Chr(10)
For Each itemFile In itemFolder.Files
Me.Text1.Text = Me.Text1.Text & itemFile & Chr(13) & Chr(10)
Next
Next
End Function
注: 要用FSO,需要引用Microsoft Scripting Runtime,窗体上要放一个text控件,用来显示。
相关文档:
Private Sub PrintTxt(txt As String, ConWidth As Long, LeftPosition As Long)
Dim str As String
Dim str1 As String
Dim len1 As Long
str = txt
len1 = ConWidth
&nbs ......
去年曾写过一篇博文,名称叫《用VB无窗口透明Usercontrol编写透明浮动按钮》,该文有一个观点是错误的,即透明无窗口Usercontrol不支持设计时点选。其实,通过在UserControl_HitTest过程里加入HitResult = vbHitResultHit语句,就可以实现设计时的点选了,为此,修改代码如下:
'* ******************* ......
Public Sub DGToExcel(DataGrid1 As DataGrid, Optional ProgressBar1 As ProgressBar, Optional ByVal intFirst As Integer, Optional ByVal intLast As Integer, Optional strTitle As String)
'--将DataGrid导出至Excel,ProgressBar1为进度条,intFirst为从哪一列开始打印,intLast为打印到哪一列
On Error Resume ......
Public Class Form1
Private Sub CmdTrans_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdTrans.Click
Dim psi As New System.Diagnostics.ProcessStartInfo
Dim ftpFileName As String
psi.FileName = "ftp.exe"
psi.RedirectStandardInput = ......