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 ......
本文来自此帖的冗长讨论,感谢Tiger_Zhao的全程指点和陈辉、阿勇、马云剑等很多朋友的热心参与。本文其他部分在:(二)、(三)、(四)。
话说VB6是个很认真细致的妈妈,它会悄没声地帮你做很多事。今天我们来说的是VB6在API调用时自动对字符串参数进行转换的“好人好事”。
第一节 体贴的VB妈 ......
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 = ......
在日常的操作系统维护过程中,有时我们也会写一些小的脚本程序来简化系统管理工作,例如调用一些WMI函数来自动安装卸载程序之类的。
在实际工作中,我发现程序员对脚本抱怨最多的就是脚本程序很难调试这个缺点,特别是调试.vbs等WSH程序的时候,总是:
1. 在资源管理器里面双击一个. ......