GRitchie Posted April 15, 2016 Posted April 15, 2016 (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 April 15, 2016 by GRitchie
spadam Posted April 15, 2016 Posted April 15, 2016 Can you post your code? Don't even know what language you're working in yet.
GRitchie Posted April 15, 2016 Author Posted April 15, 2016 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
GRitchie Posted April 15, 2016 Author Posted April 15, 2016 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
howartp Posted April 15, 2016 Posted April 15, 2016 TXT_NAME needs to be TXT_NAME.Text if the name of your textbox is called TXT_NAME. Peter 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now