Click here to Skip to main content
16,006,442 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: append line number to a text file Pin
Hurricane300010-Sep-09 8:12
Hurricane300010-Sep-09 8:12 
GeneralRe: append line number to a text file Pin
cjdc10-Sep-09 9:09
cjdc10-Sep-09 9:09 
GeneralRe: append line number to a text file Pin
Hurricane300010-Sep-09 9:30
Hurricane300010-Sep-09 9:30 
GeneralRe: append line number to a text file [modified] Pin
cjdc10-Sep-09 10:05
cjdc10-Sep-09 10:05 
GeneralRe: append line number to a text file Pin
Hurricane300010-Sep-09 10:33
Hurricane300010-Sep-09 10:33 
GeneralRe: append line number to a text file Pin
cjdc10-Sep-09 10:49
cjdc10-Sep-09 10:49 
AnswerRe: append line number to a text file Pin
Hurricane300011-Sep-09 4:54
Hurricane300011-Sep-09 4:54 
GeneralRe: append line number to a text file Solved Pin
cjdc14-Sep-09 0:25
cjdc14-Sep-09 0:25 
Hi Ignazio,

Many, many thanks for the brain refresh. I had grown tired took the weekend of to refresh.

Well thank sfor the code and a few mods and it works swell, here's what I have now and it probably could be shorter than what I have but I'm still learning. See what you think:

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If ComboBox1.SelectedItem = "" Then
            Me.Hide()
            Dialog1.ShowDialog()
            Return
        Else
        End If
        Dim fso
        Dim fol As String
        fol = "\\Sv1\technician\IT report"
        fso = CreateObject("Scripting.FileSystemObject")
        If Not fso.FolderExists(fol) Then
            fso.CreateFolder(fol)
            MsgBox(" Folder created", MsgBoxStyle.OkOnly, "Folder Created")
        Else
            MsgBox(" Log File Updated", MsgBoxStyle.OkOnly, "Log Updated")
        End If
        Dim path As String = "\\Sv1\technician\IT report\IT Report Log.txt"
        Dim sw As IO.StreamWriter

        If IO.File.Exists(path) = False Then
            sw = IO.File.CreateText(path)
            sw.WriteLine(Date.Now.ToString() + "," + ("IT Report Log File Started"))
            sw.Flush()
            sw.Close()
            IO.File.SetCreationTime(path, Date.Now())
        End If
        Using sv As IO.StreamReader = New IO.StreamReader(path)
            Dim CountLines As Integer = 0
            Dim line As String
            Do
                line = sv.ReadLine()
                If line = Nothing Then Exit Do
                CountLines = CountLines + 1
            Loop Until line Is Nothing
            sv.Close()
            CountLines = CountLines - 1 'The number 1 indicate eventually first lines to subtract.
            sw = IO.File.AppendText(path)
            CountLines = CountLines + 1
            sw.WriteLine(CountLines.ToString + ". " + DateTime.Now.ToString() + " " + (ComboBox1.Text) + "," + (TextBox1.Text) + "," + (ComboBox2.Text) + "," + "Reported by," + (ComboBox3.Text) + "," + (DateTimePicker1.Text))
        End Using
        sw.Flush()
        sw.Close()
        Dim sr As IO.StreamReader = IO.File.OpenText(path)
        Dim s As String
        Do While sr.Peek() >= 0
            s = sr.ReadLine()
            Console.WriteLine(s)
        Loop
        ComboBox1.SelectedIndex = -1
        ComboBox2.SelectedIndex = -1
        ComboBox3.SelectedIndex = -1
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        sr.Close()
    End Sub


Once again thanks to all that help with this one.
Best regards
CJ
Questioncomputer to computer communication event Pin
computbill9-Sep-09 13:09
computbill9-Sep-09 13:09 
AnswerRe: computer to computer communication event Pin
Christian Graus9-Sep-09 13:52
protectorChristian Graus9-Sep-09 13:52 
QuestionClass not registered Pin
RossouwDB9-Sep-09 9:01
RossouwDB9-Sep-09 9:01 
AnswerRe: Class not registered Pin
Christian Graus9-Sep-09 9:22
protectorChristian Graus9-Sep-09 9:22 
GeneralRe: Class not registered Pin
RossouwDB9-Sep-09 10:44
RossouwDB9-Sep-09 10:44 
GeneralRe: Class not registered Pin
Christian Graus9-Sep-09 11:20
protectorChristian Graus9-Sep-09 11:20 
GeneralRe: Class not registered Pin
RossouwDB10-Sep-09 5:01
RossouwDB10-Sep-09 5:01 
GeneralRe: Class not registered Pin
RossouwDB12-Sep-09 5:08
RossouwDB12-Sep-09 5:08 
QuestionSuspendLayout, changing Width property and ResumeLayout(True) Pin
EliottA9-Sep-09 7:46
EliottA9-Sep-09 7:46 
QuestionPossible to pass a string to a Function as name of an array? Pin
Hurricane30009-Sep-09 5:42
Hurricane30009-Sep-09 5:42 
AnswerRe: Possible to pass a string to a Function as name of an array? Pin
Dave Kreskowiak9-Sep-09 6:17
mveDave Kreskowiak9-Sep-09 6:17 
GeneralRe: Possible to pass a string to a Function as name of an array? Pin
Hurricane30009-Sep-09 7:19
Hurricane30009-Sep-09 7:19 
GeneralRe: Possible to pass a string to a Function as name of an array? Pin
Christian Graus9-Sep-09 9:26
protectorChristian Graus9-Sep-09 9:26 
GeneralRe: Possible to pass a string to a Function as name of an array? Pin
Dave Kreskowiak9-Sep-09 11:16
mveDave Kreskowiak9-Sep-09 11:16 
AnswerRe: Possible to pass a string to a Function as name of an array? Pin
dan!sh 9-Sep-09 6:26
professional dan!sh 9-Sep-09 6:26 
GeneralRe: Possible to pass a string to a Function as name of an array? [modified] Pin
Hurricane30009-Sep-09 7:30
Hurricane30009-Sep-09 7:30 
GeneralRe: Possible to pass a string to a Function as name of an array? Pin
EliottA9-Sep-09 8:52
EliottA9-Sep-09 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.