|
-
Sep 24th, 2000, 10:20 PM
#1
This is an exerpt of my code, it goes on like this 9 times! Ugh! I know I can shorten it by useing an array or an index but I havn't a clue how to make that work. Anyone feel like helping me?
Public Function MultiDirExport(ExportPath)
Dim DirExport As String
If frmMultiDir.txtDir(0).Text = "" Then
Exit Function
Else
DirExport = frmMultiDir.txtDir(0).Text
DosShell "dir /b " & DirExport & " >> C:\Windows\Temp\MP3_Export.txt"
End If
If frmMultiDir.txtDir(1).Text = "" Then
Exit Function
Else
DirExport = frmMultiDir.txtDir(1).Text
DosShell "dir /b " & DirExport & " >> C:\Windows\Temp\MP3_Export.txt"
End If
If frmMultiDir.txtDir(2).Text = "" Then
Exit Function
Else
DirExport = frmMultiDir.txtDir(2).Text
DosShell "dir /b " & DirExport & " >> C:\Windows\Temp\MP3_Export.txt"
End If
End Function
-
Sep 24th, 2000, 10:34 PM
#2
Hello Yogi_Bear_79,
You could do it this way:
Code:
Public Function MultiDirExport(ExportPath)
Dim DirExport As String
Dim I As Integer
For I = 0 To frmMultiDir.txtDir.Count
If Len(frmMultiDir.txtDir(I).Text) > 0 Then
DirExport = frmMultiDir.txtDir(I).Text
DosShell "dir /b " & DirExport & " >> C:\Windows\Temp\MP3_Export.txt"
End If
Next I
End Function
Hope this helps,
-
Sep 25th, 2000, 12:48 AM
#3
Lively Member
Your wrong Rwa, because Yogi_Bear_79 exit function after the first txtDir(i)="". The code look like this
Code:
Public Function MultiDirExport(ExportPath)
Dim DirExport As String
Dim I as integer
dim MaxI as integer
Maxi=frmMultiDir.txtDir.Count
For i=0 to MaxI
If frmMultiDir.txtDir(0).Text = "" Then
Exit Function
Else
DirExport = frmMultiDir.txtDir(0).Text
DosShell "dir /b " & DirExport & " >> C:\Windows\Temp\MP3_Export.txt"
End If
Next
End Function
-
Sep 25th, 2000, 07:49 AM
#4
Well there KWell,
Your code will only check one textbox:
If frmMultiDir.txtDir(0).Text = "" Then
Then finish looping while checking nothing. I think my code will work a little better. It will write to the log file if any of the textbox's have text in them.
Best,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|