-
Reading and writing lines from a text file...
Hi there...
I am trying to make a winsock control send a line from a text file once every minite.
so if the text file had 5 lines, it would send a line every minite then go and start from the top again...
First of all, I want to make it so that when a form loads, the text box in it will say the same as the text in the text file.
Then If the user wants to edit the text file, or add a line to it, it can be saved....
Then I want the winsock to send each line from the text file individually at an interval of 1 minite.
Do I can do it with textboxes and a timer, eg
timerinerval being 60000,
Code:
TIMER1
wsk.senddata text1.text
timer1.enabled = false
timer2.enabled = true
TIMER2
wsk.senddata text2.text
timer2.enabled = false
timer1.enabled = true
that then just keeps sending the text in the text boxes over and over, (which is what i want) but That can't save the text in the textboxes and limits the amount of messages by the amount of text boxes you have....
i would be grateful of any help
Jenks
Last edited by Jenks; 05-21-2005 at 08:45 AM.
-
Can you be more specific as to what part of this scenario you are having trouble with?
Bob Rouse
Dimension Data
-
BAsically, I want a winsock control to send a line of data every minite.
So If I had a text file with the data I want to send looking like this....
Code:
Welcome to my server
I Hope you enjoy your stay
Then I would want the winsock control to send the first line "Welcome....Server" then wait 1 minite and then send the second line "I hope....Stay", then repleat the cycle.
Thanks
Jenks
-
First, (if storing the values in a text file) you can read the text file into a "hidden" listbox control (set Visible = False). Then using a timer control (or the timer APIs - depending on how accurate that 1 minute needs to be), loop through the list:
Code:
Dim intPos as integer
Sub Timer1_Timer()
Dim strMsg as String
' Start over if at the end of the list
If intPos = List1.ListCount then
intPos = 0
End If
' Get the message
strMsg = List1.List(intPos)
' Send it...
Bob Rouse
Dimension Data
-
ok thanks,
would that code get the first line in the list box, if so which bit would I change to read the 2nd line etc...
-
ok thanks,
would that code get the first line in the list box, if so which bit would I change to read the 2nd line etc...
and what code would I use to read the fiel into the list box
Jenks
-
To get the file into the list box, I would recommend using the Microsoft Scripting Runtime library: http://msdn.microsoft.com/library/de...filesystem.asp
Open the file using a "File" object to load it into a "TextStream" object, and loop through the file getting each line with the "ReadLine" method of the "TextStream" object and add it to the list box using the listbox's "AddItem" method.
Bob Rouse
Dimension Data
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks