Private Sub Form_Load()
Dir1.Path = "\\DB server\D\共用文件\ABC"
File1.Path = Dir1.Path
End Sub
還是有其他方式能解決的呢?
我是以下程式為參考點,程式選單拉了一個DrivelistBox 一個dirlistBox 一個FilelistBox
一個PictureBox ,但我只需要留一個FilelistBox能顯示我指定的資料夾
但是我將其他不會用到的移除拿掉程式碼此程式執行就有錯誤了
拿掉Drive1與Dir1就會錯誤
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Dim f_name, f2_name, context As String
Dim i, j, k As Integer
f_name = File1.Path & "\" & File1.List(File1.ListIndex)
f2_name = "out.txt"
Open f_name For Input Access Read As #1
Open f2_name For Output Access Write As #2
context = ""
Do While Not EOF(1)
Input #1, j, k
Picture1.Circle (j, Picture1.ScaleHeight - k), 0.1
Write #2, j, k
Loop
Close #1
Close #2
End Sub
Private Sub Form_Load()
Dir1.Path = "C:"
File1.Path = Dir1.Path
Picture1.BackColor = RGB(255, 255, 255)
End Sub
如果你的需求是【只想讓使用者登入至Terminal Server執行此執行檔時只出現DB server共用文件底下的ABC目錄資料夾的Excel.xls】,那就不需要 Dirver, Dir 元件,只需要一個 FileListBox,並直接把路徑寫死在 FileListBox 就行了。如下列範例程式(雙擊檔名會開啟所選的 xls 檔案):
<pre class="c" name="code">Private Sub File1_DblClick()
Shell """C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"" " & Chr(34) & File1.Path & "" & File1.FileName & Chr(34), vbNormalFocus
End Sub
Private Sub Form_Load()
File1.Path = "\DB server\D\共用文件\ABC"
File1.Pattern = ".xls;.xlsx"
End Sub
注意,在 Terminal Server 必須安裝 excel,上面程式 excel.exe 的目錄依你所安裝的目錄修改。
2. 在 DB server 的共用文件目錄,應設定只能由 Terminal Server 存取。