Jump to content

Recommended Posts

Posted (edited)

I'm trying to write a program where users will write their name in a text box, hit save and it write out to "C:\Users\Logins.txt" with 'DATE__TIME__TEXTBOX'

 

But I don't seem to be having much luck.

Currently it writes out all sorts of code as well as the content from the text box, and I don't know how to get it to write the date/time. Thoughts?

Thanks!

 

EDIT: Writing in VB

Edited by GRitchie
Posted

Oh sorry my bad - it's VB :-)

  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


       Dim file As System.IO.StreamWriter
       file = My.Computer.FileSystem.OpenTextFileWriter("C:\Login\Users.txt", True)
       file.WriteLine(TXT_NAME)
       file.Close()
       Application.Exit()


   End Sub

Posted

Okay - I've got the date and time working with the following code. But the line which does file.WriteLine(TXT_NAME) outputs like this: System.Windows.Forms.TextBox, Text: test

How can I clean that up?

 

Public Class Form1

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


       Dim file As System.IO.StreamWriter
       Dim dt As String
       dt = Format(Now(), "dd-MM-yyyy hh:mm:ss")


       file = My.Computer.FileSystem.OpenTextFileWriter("C:\Login\Users.txt", True)
       file.WriteLine(dt)
       file.WriteLine(TXT_NAME)
       file.WriteLine("###################################")
       file.Close()
       Application.Exit()


   End Sub
End Class

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...