Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

On button click, add current time and date to txt file in web

like the title say

when the button is clicked i want it to send the current date and time to txt file (log file)
also userTextBox.Text, so i can see it in this format

username: HackForumsUser
Date: 28/02/2019
Time: 20:58

And then when i click the button again, i want it to add the new one after the old one for example:


username: HackForumsUser
Date: 28/02/2019
Time: 20:58

username: HackForumsUser2
Date: 29/02/2019
Time: 22:58

username: HackForumsUser3
Date: 22/03/2019
Time: 21:58
I gotchu, posting to update later.

EDIT:

Things Needed:
  • 2 Textboxes

  • 2 Buttons

  • Imports system.IO

  • Publicly declare: Dim los As New List(Of String)



[Image: 00787c273e5b94fc8f230f1f1388a87d.png]

Add Button:
Code
Dim packet As String = "Username: " & TextBox2.Text & vbNewLine & "Date: " & Date.Now & vbNewLine & "Time:" & TimeOfDay
       TextBox1.Text = TextBox1.Text & vbNewLine & packet
       los.Add(packet)

Save Button:
Code
File.WriteAllLines(Environment.CurrentDirectory & "Saved.txt", los)

Full Code:
Code
Imports System.IO

Public Class Form1

   Dim los As New List(Of String)
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim packet As String = "Username: " & TextBox2.Text & vbNewLine & "Date: " & Date.Now & vbNewLine & "Time:" & TimeOfDay
       TextBox1.Text = TextBox1.Text & vbNewLine & packet
       los.Add(packet)

   End Sub

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
       File.WriteAllLines(Environment.CurrentDirectory & "Saved.txt", los)
   End Sub
End Class
(Feb 28, 2019 02:00 PM)Who Soup Wrote:  I gotchu, posting to update later.

EDIT:

Things Needed:
  • 2 Textboxes

  • 2 Buttons

  • Imports system.IO

  • Publicly declare: Dim los As New List(Of String)



[Image: 00787c273e5b94fc8f230f1f1388a87d.png]

Add Button:
Code
Dim packet As String = "Username: " & TextBox2.Text & vbNewLine & "Date: " & Date.Now & vbNewLine & "Time:" & TimeOfDay
       TextBox1.Text = TextBox1.Text & vbNewLine & packet
       los.Add(packet)

Save Button:
Code
File.WriteAllLines(Environment.CurrentDirectory & "Saved.txt", los)

Full Code:
Code
Imports System.IO

Public Class Form1

   Dim los As New List(Of String)
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim packet As String = "Username: " & TextBox2.Text & vbNewLine & "Date: " & Date.Now & vbNewLine & "Time:" & TimeOfDay
       TextBox1.Text = TextBox1.Text & vbNewLine & packet
       los.Add(packet)

   End Sub

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
       File.WriteAllLines(Environment.CurrentDirectory & "Saved.txt", los)
   End Sub
End Class

Awesome bro, Thank you!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by MarwenSep 24, 2022 04:19 PM 10 639 Sep 24, 2022 04:19 PM
Last Post: BinaryFox
[C#] by BBGMazeJun 2, 2022 06:17 PM 2 163 Jun 2, 2022 06:17 PM
Last Post: Prisonhack9279
[Python] by The Pulp FictionApr 24, 2022 12:22 AM 2 200 Apr 24, 2022 12:22 AM
Last Post: The Pulp Fiction