一点新手的帮助
好的,我已经用VBA玩了大约一个星期,只是写了一些小东西,看看我能做什么和不能做什么。我从帮助文件中得到了这个小片段,并根据需要对其进行了修改Public Sub GetFolderList(BlockLibrary As String)
Dim FileName As String
Dim FileList() As Variant
Dim Counter As Single
' Display the names of the files that represent directories.
FileName = Dir(BlockLibrary, vbDirectory) ' Retrieve the first entry.
Counter = 0
ReDim FileList(Counter)
Do While FileName"" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If FileName"." And FileName".." Then
' Use bitwise comparison to make sure FileName is a directory.
If (GetAttr(BlockLibrary & FileName) And vbDirectory) = vbDirectory Then
Debug.Print FileName ' Display entry only if it
FileList(Counter) = FileName
ReDim Preserve FileList(Counter + 1)
Counter = (1 + Counter)
End If ' it represents a directory.
End If
FileName = Dir ' Get next entry.
Loop
End Sub
然而,我有一个问题
它看起来正常吗
我可以在函数中使用此子函数填充列表框吗
此外,我还尝试了几种方法来获取此代码,并将扩展名传递给它,以获得该文件类型的列表
谢谢
**** Hidden Message ***** 嘿,Vicious D. Timothy Slither:
我使用了以下代码。
Option Explicit
Public DirectoryListArray() As String
Public Sub Main()
Dim MyFile As String
Dim Counter As Long
ReDim DirectoryListArray(1000)
MyFile = Dir$("c:\temp\*.dwg")
Do While MyFile""
DirectoryListArray(Counter) = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop
ReDim Preserve DirectoryListArray(Counter - 1)
End Sub
然后使用以下命令加载列表框。
ListBox1.List = DirectoryListArray
感谢Matt(又名Trick Magnet M.Flava)
代码示例帮助我从LISP过渡到VB(a)
,我一直在编写小模块triing,以完成LISP中简单的小事情
新问题。我应该在创建新子模块时添加模块,还是只添加一个大模块<再次感谢 不客气
我看到它有3种不同的方式:
1)将所有子模块集中到一个模块中(我不太在意)
2)为每个子模块分别设置模块(也不在乎)
3)将子模块分组到不同的模块中(这就是我试图做的)。例如,注册表代码的所有子模块将位于一个模块中;用于文件操作的所有子模块将位于另一个模块中;等等<我想有一种“推荐”的方法。这是什么,我不知道。我喜欢选项#3,我会坚持下去,因为它一直在为我工作。 我已经开始做选项3了。所有的层功能在一个,所有的文件夹功能在另一个,等等,它似乎工作得很干净。
我一直用这种方式写我的lisp。都在一个文件里,但是我把文件分成几个部分。
看起来更干净。谢谢 在决定将代码放在何处(就模块而言)时要记住的一件事是其中包含的变量/函数的范围。 您需要知道模块何时“加载”和“卸载”,以便弄清楚模块中包含的全局变量何时“消失”。 当你谈论模块时,它并没有那么大的区别。 但是当你谈论课程时,它确实如此。 我也使用选项3。 我为图层,文本,标题块等制作单独的dvb文件,然后为不同的子模块使用模块,最后将类似的子组在1个模块中。 我希望这是有道理的
页:
[1]