hi all
i am right now examing one of the project thats avaliable.in which they have taken single log file as input. the code for it is given below. - Private Sub cmdInputBrowse_Click()
-
On Error GoTo ErrorLine
-
Dim fname As String
-
Dim fso As New FileSystemObject
-
Dim ext, newext As Variant
-
Dim stat, i As Integer
-
stat = 0
-
-
If txtInputPath.Text <> "" Then
-
If fso.FileExists(txtInputPath.Text) Then
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
ElseIf fso.FolderExists(txtInputPath.Text) Then
-
fname = txtInputPath.Text
-
Else
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
-
If InStr(1, txtInputPath.Text, ".") > 0 Then
-
ext = "*." & Split(Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1), ".")(1)
-
Else
-
ext = "*.csv"
-
End If
-
MsgBox ext
-
stat = 1
-
End If
-
-
If Not fso.FolderExists(fname) Then
-
MsgBox "Folder specified does not exist", , "Input Log File"
-
txtInputPath.Text = ""
-
Exit Sub
-
End If
-
-
CDBrowseFile.InitDir = fname
-
Else
-
CDBrowseFile.InitDir = App.Path
-
End If
-
-
CDBrowseFile.Filter = "*.csv|*.csv;" & Chr(124) & "*.log|*.log;" & Chr(124) & "*.txt|*.txt" & Chr(124) & "*.*|*.*"
-
-
-
-
CDBrowseFile.DialogTitle = "Select the Log File"
-
-
-
If stat = 0 Then
-
CDBrowseFile.FilterIndex = 1
-
Else
-
If ext = "*.csv" Then
-
CDBrowseFile.FilterIndex = 1
-
ElseIf ext = "*.log" Then
-
CDBrowseFile.FilterIndex = 2
-
ElseIf ext = "*.txt" Then
-
CDBrowseFile.FilterIndex = 3
-
Else
-
CDBrowseFile.FilterIndex = 4
-
End If
-
End If
-
CDBrowseFile.ShowOpen
-
If CDBrowseFile.FileName <> "" Then
-
If fso.FileExists(CDBrowseFile.FileName) = True Then
-
txtInputPath.Text = CDBrowseFile.FileName
-
gstrInputFile = Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1)
-
CmdCompute.Enabled = True
-
CDBrowseFile.FileName = ""
-
Else
-
MsgBox "File does not exist", vbCritical, "Input File"
-
End If
-
End If
-
If txtInputPath.Text <> "" Then
-
TxtOutputPath.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1)
-
End If
-
-
If TxtInputTimerFile.Text = "" Then
-
TxtInputTimerFile.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1) & "\"
-
End If
-
Exit Sub
-
-
ErrorLine:
-
'MsgBox "Error-Number:" & Err.Number & vbCrLf & "Error Description:" & Err.DESCRIPTION & vbCrLf & "Error At: Selecting input file"
-
End Sub
the extensions that are specified here are log files extensions.... can i enhance this code to take in multiple log files as input...if i can then where should i edit the existing code to take multiple files..
can anyone guide me in this
awating a reply
thanks in advance for whatever help i get
thanks
sairaam
8 1766 -
1. CDBrowseFile.Filter = "*.csv|*.csv;" & Chr(124) & "*.log|*.log;" & Chr(124) & "*.txt|*.txt" & Chr(124) & "*.*|*.*"
-
-
-
-
2. CDBrowseFile.DialogTitle = "Select the Log File"
-
-
-
3. If stat = 0 Then
-
4. CDBrowseFile.FilterIndex = 1
Line one in code above controls which file extensions to show.
You can change file index in line 4 to a different number like. - CDBrowseFile.FilterIndex = 3
Good Luck.
One thing I would recommend is to move the browsing code into a separate Sub, rather than having it hanging off a button like this. Once you encapsulate it as a self-contained routine, it becomes much simpler to reuse it or change the way that you call it.
-
1. CDBrowseFile.Filter = "*.csv|*.csv;" & Chr(124) & "*.log|*.log;" & Chr(124) & "*.txt|*.txt" & Chr(124) & "*.*|*.*"
-
-
-
-
2. CDBrowseFile.DialogTitle = "Select the Log File"
-
-
-
3. If stat = 0 Then
-
4. CDBrowseFile.FilterIndex = 1
Line one in code above controls which file extensions to show.
You can change file index in line 4 to a different number like. - CDBrowseFile.FilterIndex = 3
Good Luck.
hi
i had changed the file index as you had specified.... but now also am not able to select multiple files... the selection here i mean selecting more than 1 file at a stroke....
can u help me
thanks
sairaam
One thing I would recommend is to move the browsing code into a separate Sub, rather than having it hanging off a button like this. Once you encapsulate it as a self-contained routine, it becomes much simpler to reuse it or change the way that you call it.
sir am not allowed to change the existing code entirely... can just modify it so cant move into a sub since the existing buutton system should be present....can u suggest me some other idea
thanks for suggestion
thanks
sairaam
Sorry, at first I didn't really understand your question correctly.
Make your textbox MultiLine = True
Use code below. -
Private Sub Command1_Click()
-
On Error GoTo ErrorLine
-
Dim fname As String
-
Dim fso As New FileSystemObject
-
Dim ext, newext As Variant
-
Dim stat, i As Integer
-
stat = 0
-
-
If txtInputPath.Text <> "" Then
-
If fso.FileExists(txtInputPath.Text) Then
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
ElseIf fso.FolderExists(txtInputPath.Text) Then
-
fname = txtInputPath.Text
-
Else
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
-
If InStr(1, txtInputPath.Text, ".") > 0 Then
-
ext = "*." & Split(Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1), ".")(1)
-
Else
-
ext = "*.csv"
-
End If
-
MsgBox ext
-
stat = 1
-
End If
-
-
If Not fso.FolderExists(fname) Then
-
MsgBox "Folder specified does not exist", , "Input Log File"
-
txtInputPath.Text = ""
-
Exit Sub
-
End If
-
-
CDBrowseFile.InitDir = fname
-
Else
-
CDBrowseFile.InitDir = App.Path
-
End If
-
-
CDBrowseFile.Filter = "*.csv|*.csv;" & Chr(124) & "*.log|*.log;" & Chr(124) & "*.txt|*.txt" & Chr(124) & "*.*|*.*"
-
CDBrowseFile.Flags = cdlOFNAllowMultiselect
-
-
-
CDBrowseFile.DialogTitle = "Select the Log File"
-
-
-
If stat = 0 Then
-
CDBrowseFile.FilterIndex = 1
-
Else
-
If ext = "*.csv" Then
-
CDBrowseFile.FilterIndex = 1
-
ElseIf ext = "*.log" Then
-
CDBrowseFile.FilterIndex = 2
-
ElseIf ext = "*.txt" Then
-
CDBrowseFile.FilterIndex = 3
-
Else
-
CDBrowseFile.FilterIndex = 4
-
End If
-
End If
-
-
-
CDBrowseFile.ShowOpen
-
If CDBrowseFile.FileName <> "" Then
-
Dim retFiles, j As Integer
-
retFiles = Split(CDBrowseFile.FileName, " ")
-
If UBound(retFiles) = 0 Then
-
txtInputPath.Text = retFiles(0)
-
Else
-
For j = 1 To UBound(retFiles)
-
txtInputPath.Text = txtInputPath.Text & vbCrLf & retFiles(0) & "\" & retFiles(j)
-
Next
-
End If
-
' If fso.FileExists(CDBrowseFile.FileName) = True Then
-
' txtInputPath.Text = CDBrowseFile.FileName
-
' gstrInputFile = Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1)
-
' CmdCompute.Enabled = True
-
' CDBrowseFile.FileName = ""
-
' Else
-
' MsgBox "File does not exist", vbCritical, "Input File"
-
' End If
-
End If
-
-
If txtInputPath.Text <> "" Then
-
TxtOutputPath.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1)
-
End If
-
-
If TxtInputTimerFile.Text = "" Then
-
TxtInputTimerFile.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1) & "\"
-
End If
-
Exit Sub
-
-
ErrorLine:
-
'MsgBox "Error-Number:" & Err.Number & vbCrLf & "Error Description:" & Err.DESCRIPTION & vbCrLf & "Error At: Selecting input file"
-
End Sub
I commented out some of your code because wasn't sure how you want to change it with multiple files:
[PHP]
' If fso.FileExists(CDBrowseFile.FileName) = True Then
' txtInputPath.Text = CDBrowseFile.FileName
' gstrInputFile = Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1)
' CmdCompute.Enabled = True
' CDBrowseFile.FileName = ""
' Else
' MsgBox "File does not exist", vbCritical, "Input File"
' End If[/PHP]
Good Luck.
Sorry, at first I didn't really understand your question correctly.
Make your textbox MultiLine = True
Use code below. -
Private Sub Command1_Click()
-
On Error GoTo ErrorLine
-
Dim fname As String
-
Dim fso As New FileSystemObject
-
Dim ext, newext As Variant
-
Dim stat, i As Integer
-
stat = 0
-
-
If txtInputPath.Text <> "" Then
-
If fso.FileExists(txtInputPath.Text) Then
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
ElseIf fso.FolderExists(txtInputPath.Text) Then
-
fname = txtInputPath.Text
-
Else
-
fname = Split(txtInputPath.Text, Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1))(0)
-
-
If InStr(1, txtInputPath.Text, ".") > 0 Then
-
ext = "*." & Split(Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1), ".")(1)
-
Else
-
ext = "*.csv"
-
End If
-
MsgBox ext
-
stat = 1
-
End If
-
-
If Not fso.FolderExists(fname) Then
-
MsgBox "Folder specified does not exist", , "Input Log File"
-
txtInputPath.Text = ""
-
Exit Sub
-
End If
-
-
CDBrowseFile.InitDir = fname
-
Else
-
CDBrowseFile.InitDir = App.Path
-
End If
-
-
CDBrowseFile.Filter = "*.csv|*.csv;" & Chr(124) & "*.log|*.log;" & Chr(124) & "*.txt|*.txt" & Chr(124) & "*.*|*.*"
-
CDBrowseFile.Flags = cdlOFNAllowMultiselect
-
-
-
CDBrowseFile.DialogTitle = "Select the Log File"
-
-
-
If stat = 0 Then
-
CDBrowseFile.FilterIndex = 1
-
Else
-
If ext = "*.csv" Then
-
CDBrowseFile.FilterIndex = 1
-
ElseIf ext = "*.log" Then
-
CDBrowseFile.FilterIndex = 2
-
ElseIf ext = "*.txt" Then
-
CDBrowseFile.FilterIndex = 3
-
Else
-
CDBrowseFile.FilterIndex = 4
-
End If
-
End If
-
-
-
CDBrowseFile.ShowOpen
-
If CDBrowseFile.FileName <> "" Then
-
Dim retFiles, j As Integer
-
retFiles = Split(CDBrowseFile.FileName, " ")
-
If UBound(retFiles) = 0 Then
-
txtInputPath.Text = retFiles(0)
-
Else
-
For j = 1 To UBound(retFiles)
-
txtInputPath.Text = txtInputPath.Text & vbCrLf & retFiles(0) & "\" & retFiles(j)
-
Next
-
End If
-
' If fso.FileExists(CDBrowseFile.FileName) = True Then
-
' txtInputPath.Text = CDBrowseFile.FileName
-
' gstrInputFile = Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1)
-
' CmdCompute.Enabled = True
-
' CDBrowseFile.FileName = ""
-
' Else
-
' MsgBox "File does not exist", vbCritical, "Input File"
-
' End If
-
End If
-
-
If txtInputPath.Text <> "" Then
-
TxtOutputPath.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1)
-
End If
-
-
If TxtInputTimerFile.Text = "" Then
-
TxtInputTimerFile.Text = Mid(txtInputPath.Text, 1, InStrRev(txtInputPath.Text, "\") - 1) & "\"
-
End If
-
Exit Sub
-
-
ErrorLine:
-
'MsgBox "Error-Number:" & Err.Number & vbCrLf & "Error Description:" & Err.DESCRIPTION & vbCrLf & "Error At: Selecting input file"
-
End Sub
I commented out some of your code because wasn't sure how you want to change it with multiple files:
[PHP]
' If fso.FileExists(CDBrowseFile.FileName) = True Then
' txtInputPath.Text = CDBrowseFile.FileName
' gstrInputFile = Mid(txtInputPath.Text, InStrRev(txtInputPath.Text, "\") + 1)
' CmdCompute.Enabled = True
' CDBrowseFile.FileName = ""
' Else
' MsgBox "File does not exist", vbCritical, "Input File"
' End If[/PHP]
Good Luck.
am really thankful for the guidence that you are doing... here am able to select muliple files but am not able to display them on to the input path...i set that text box multiline property to true also....
can i have any suggessions for it..
thanks
sairaam
am in urgent need please can some one help me out...to solve the problem which i have mentioned earlier...
thanks
sairaam
Yeh that is one thing i wanted to know as well
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Riccardo Galli |
last post by:
Hi,
I noticed that when I use os.listdir I need to work with absolute paths
90% of times.
While I can use a for cycle, I'd prefere to use a list comprehension,
but it becomes too long.
I...
|
by: Dalan |
last post by:
I have been using a module for printing labels in Access 97, and
although it works fine, I would like to add a small enhancement to it.
The module allows for setting the number of labels to print...
|
by: David Logan |
last post by:
We need an additional function in the String class. We need the ability
to suppress empty fields, so that we can more effectively parse. Right
now, multiple whitespace characters create multiple...
|
by: cody |
last post by:
What about an enhancement of foreach loops which allows a syntax like that:
foeach(int i in 1..10) { } // forward
foeach(int i in 99..2) { } // backwards
foeach(char c in 'a'..'z') { } // chars...
|
by: Kieran Benton |
last post by:
Hello,
I'm currently in the tail end process of developing a high scalability
server for my employer. Essentially it receives short socket based
connections with an ASCII message, parses that...
|
by: skyy |
last post by:
Hi.. i would like to know how to handle multiple upload files with the cgi module in perl script..
With single file,
my $my_cgi new CGI;
my $upload_filehandle = cgi ->upload('file1');
my...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |