Here dude, this first set of code gets the specified file and then
reads from it. The second set of code creates a .txt file and then
adds lines of info into the file then creates a new file each day
after midnight. This is was used for one of our older applications
written in vb 6 so you will have to figure out how to make it work for
you.
Public Function GetFile(ByVal File As String) As String
Dim Path As String
Dim FF As Integer
On Error GoTo ErrHandler
'Check if file includes path
If InStr(File, "\") = 0 Then
Path = App.Path
If Right(Path, 1) <> "\" Then
File = Path & "\" & File
Else
File = Path & File
End If
End If
'Read file in one pass
FF = FreeFile
Open File For Input As #FF
GetFile = Input(LOF(FF), FF)
Close FF
Exit Function
ErrHandler:
Err.Description = "GetFile: " & Err.Description & " -> " & File
Err.Raise Err.Number
End Function
**********************************
Second Subroutine for creating the file
**********************************
Public Sub CreateLogFile(sMessage)
'Dim fs As FileSystemObject
Dim ts As TextStream
Dim sFile As String
Dim isOpen As Boolean
Dim Fnum As Long
Dim iLog As Integer
Dim sFiledate As String
Dim dDate As Date
Dim sdate As String
Dim chkDate As String
Dim dFile As String
Dim i
Dim FileDate As Date
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(App.Path & "\logs\rptlogs")
Fnum = FreeFile
Dim objFile
sFile = App.Path & "\logs\rptlogs\rptlog_" & DateTime.Date$ &
".log"
sFiledate = Left(Right(sFile, (Len(sFile) - (InStr(sFile,
DateTime.Date$) - 1))), 10)
dDate = CDate(sFiledate)
For Each objFile In f.Files
sdate = Left(Right(objFile.Name, (Len(objFile.Name) - 7)), 10)
FileDate = CDate(sdate)
If (FileDate < Now - 3) Then
objFile.Delete
End If
Next
If isOpen Then Close #Fnum
Open sFile For Append As #Fnum
isOpen = True
Print #Fnum, sMessage
Close #Fnum
End Sub
=====================================
On Sep 10, 9:41 am, Jai <[EMAIL PROTECTED]> wrote:
> Im finishing up my last semester for my associates degree, and I took
> beginning VB over three years ago. Now that Im back in school Im in
> Advanced VB. Originally I caught on to VB like a pro, now Im looking
> at it like it's another "language" haha!
>
> I have my old notes and notebook, and Im starting to recall some
> things but Im having major problems.
>
> This is the problem Im working on:
> Read 10 digits contained in a text file into an array and then display
> three columns in a list box as follows: column 1 should contain the
> original 10 digits, column 2 should contain them in reverse order, and
> column 3 should contain the averages of the corresponding digits'
> numbers in columns 1 and 2.
>
> Can anyone write the code for me and suggest how to set the form up?
> Im so lost and your help would be GREATLY appreciated!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---