471,873 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Help with auto updating a .text file

6
Hello, I'm pretty new at trying to do things in visual basic and I've been following some steps to do a few things like writing to a .txt file and reading from that same .txt file.
Link for writing to a text file
Link for reading from a text file

so lets say that I have a brother and we are using 2 different computers over a network and we are communicating via this program on the network

I type something into the text box and it get's saved to the notepad and he clicks a button and get's what I typed into the notepad printed onto his screen.
Here is what I'm trying to do
I'm trying to make it so that if one of us checks a "checkbox" on the form that it will automatically update the list every time one of us types something and saves it to that .txt file.so they don't have to manually click a button every minute to check for something one of us typed.

I've got most of the code working (which isn't much) but I'm having trouble with the autoupdate checkbox. Any help would be appreciated
Jan 5 '07 #1
4 1626
willakawill
1,646 1GB
Hello, I'm pretty new at trying to do things in visual basic and I've been following some steps to do a few things like writing to a .txt file and reading from that same .txt file.
Link for writing to a text file
Link for reading from a text file

so lets say that I have a brother and we are using 2 different computers over a network and we are communicating via this program on the network

I type something into the text box and it get's saved to the notepad and he clicks a button and get's what I typed into the notepad printed onto his screen.
Here is what I'm trying to do
I'm trying to make it so that if one of us checks a "checkbox" on the form that it will automatically update the list every time one of us types something and saves it to that .txt file.so they don't have to manually click a button every minute to check for something one of us typed.

I've got most of the code working (which isn't much) but I'm having trouble with the autoupdate checkbox. Any help would be appreciated
Hi. You can use a timer control and set the timer event to check the file for you rather than a button
Jan 5 '07 #2
Killer42
8,435 Expert 8TB
Hi. You can use a timer control and set the timer event to check the file for you rather than a button
Yes, all the checkbox control would need to do is set the Enabled property of the Timer control to True or False. Don't forget to set the Interval property of the timer control when you place it on the form - probably to something like 60000.
Jan 5 '07 #3
bmruze
6
Yes, all the checkbox control would need to do is set the Enabled property of the Timer control to True or False. Don't forget to set the Interval property of the timer control when you place it on the form - probably to something like 60000.
something like this?

Private Sub AutoUpdateCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoUpdateCheckBox.CheckedChanged
Dim textboxreader As String
With Me
If .AutoUpdateCheckBox.Checked = True Then Timer1.Enabled = True
Timer1.Start()
If Timer1.Equals(1000) Then
textboxreader = My.Computer.FileSystem.ReadAllText("C:\Users\Deskt op\mytextfile.txt")
.inTextbox.Text = textboxreader
End If
End With
End Sub
End Class
Jan 6 '07 #4
willakawill
1,646 1GB
something like this?

Private Sub AutoUpdateCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoUpdateCheckBox.CheckedChanged
Dim textboxreader As String
With Me
If .AutoUpdateCheckBox.Checked = True Then Timer1.Enabled = True
Timer1.Start()
If Timer1.Equals(1000) Then
textboxreader = My.Computer.FileSystem.ReadAllText("C:\Users\Deskt op\mytextfile.txt")
.inTextbox.Text = textboxreader
End If
End With
End Sub
End Class
Not quite. You are using vb.NET so I don't have experience of the timer control in that environment. Look for the timer event for the control. When you activate the timer it should create a timer event when it reaches the time set.
Jan 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Alpha | last post: by
6 posts views Thread by Jeff | last post: by
1 post views Thread by innivive | last post: by
reply views Thread by richard12345 | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.