Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Get the "changed" data from a _chage textbox event


Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2004, 12:53 PM
Twigathy Twigathy is offline
Newcomer
 
Join Date: Feb 2004
Posts: 9
Default Get the "changed" data from a _chage textbox event


Hi there,

Im Fairly new to all this stuff, how do I get the text that has changed on a _change event? At the moment i'm using the following code:

Code:
Private Sub txtRecieved_Change() If AutoLog = True Then Dim FileName As String Dim FileNumber As Integer Dim DataToWrite As String 'Define the variables [well no * * * *] DataToWrite = vbCrLf & txtRecieved.n FileName = App.Path & "\Logs\" & Date$ & ".txt" 'This makes sure the file saved is in the same dir as the application. Else it gets saved 'in the same directory as the thingy being listed... FileNumber = FreeFile() 'Set the file number to a "free file" Open FileName For Append As FileNumber 'Open the file for APPENDING (See the tut for details about different modes) Write #FileNumber, DataToWrite Close FileNumber End If End Sub

Note that the "AutoLog" is defined under the general declarations thingy, and its changed by another function (Which is in an options menu)

The thing is that this produces log files that look like the one below. Two questions really:

1) How to get rid of the " marks where new stuff is being written
2) How to return the changed text so I only write to the text file what has changed

Much thanks

Twigathy
Reply With Quote
  #2  
Old 03-05-2004, 01:36 PM
noi_max's Avatar
noi_max noi_max is offline
Still asleep...

Retired Leader
* Expert *
 
Join Date: Nov 2003
Location: IronForge
Posts: 2,694
Default

Is the user going to type in a new value in the textbox?

Somehow I don't see this as the best option. It looks like when the textbox changes the file gets saved. The change event will fire every time something is typed into the textbox. Unless the textbox is being updated some other way.
__________________
~ Jason

Use [vb][/vb] tags when posting code :) || Search the forum and MSDN|| Check out the Posting Guidelines
Reply With Quote
  #3  
Old 03-05-2004, 01:47 PM
Twigathy Twigathy is offline
Newcomer
 
Join Date: Feb 2004
Posts: 9
Default

Figured something new out. Instead of logging when new data arrives into the textbox I stuck the code into the Winsock-data recieved bit, so now it looks like this:

Code:
Private Sub WinsockClient_DataArrival(ByVal bytesTotal As Long) Dim strMessage As String Dim FileName As String Dim FileNumber As Integer Dim DataToWrite As String 'Define variables WinsockClient.GetData strMessage 'Get the message from the winsock cache frmChat.txtRecieved.Text = frmChat.txtRecieved.Text & vbCrLf & strMessage If AutoLog = True Then DataToWrite = vbCrLf & strMessage FileName = App.Path & "\Logs\" & Date$ & ".txt" 'This makes sure the file saved is in the same dir as the application. Else it gets saved 'in the same directory as the thingy being listed... FileNumber = FreeFile() 'Set the file number to a "free file" Open FileName For Append As FileNumber 'Open the file for APPENDING (See the tut for details about different modes) Write #FileNumber, DataToWrite Close FileNumber End If End Sub

However, i'm still interested to know how I would find the answer to my first questions. Mainly the fact that every time the text file gets written to it has Quote (") marks round the text.
Reply With Quote
  #4  
Old 03-05-2004, 01:48 PM
thingimijig thingimijig is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Posts: 1,300
Default

use Print instead of Write

thingimijig.
Reply With Quote
  #5  
Old 03-05-2004, 02:02 PM
Twigathy Twigathy is offline
Newcomer
 
Join Date: Feb 2004
Posts: 9
Default

Solved it in a kind of round about way :/

Heres the menu code:
Code:
Private Sub mnuOptionsAutoLog_Click() If mnuOptionsAutoLog.Checked = False Then mnuOptionsAutoLog.Checked = True lblAutoLog.Caption = "Enabled" MsgBox "Autologging is Enabled", vbInformation, "LAN Share" Else mnuOptionsAutoLog.Checked = False lblAutoLog.Caption = "Disabled" MsgBox "Autologging is Disabled", vbInformation, "LAN Share" End If End Sub

And heres what happens when a connection is recieved:
Code:
Private Sub WinsockClient_DataArrival(ByVal bytesTotal As Long) Dim strMessage As String Dim FileName As String Dim FileNumber As Integer Dim DataToWrite As String 'Define variables WinsockClient.GetData strMessage 'Get the message from the winsock cache frmChat.txtRecieved.Text = frmChat.txtRecieved.Text & vbCrLf & strMessage If frmChat.lblAutoLog.Caption = "Enabled" Then DataToWrite = vbCrLf & strMessage FileName = App.Path & "\Logs\" & Date$ & ".txt" 'This makes sure the file saved is in the same dir as the application. Else it gets saved 'in the same directory as the thingy being listed... FileNumber = FreeFile() 'Set the file number to a "free file" Open FileName For Append As FileNumber 'Open the file for APPENDING (See the tut for details about different modes) Write #FileNumber, DataToPrint Close FileNumber End If End Sub

Is there a better way of passing data between forms other than using labels? Seems kind of silly to me, although my label is visible to to the user to they can see the status of autologging

btw, this project can be found at sourceforge

Thanks for your help
Reply With Quote
  #6  
Old 03-05-2004, 02:48 PM
PWNettle PWNettle is offline
Verbose Coder

Retired Moderator
* Guru *
 
Join Date: Dec 1999
Location: Phoenix, Arizona
Posts: 3,011
Default

Quote:
Originally Posted by Twigathy
Is there a better way of passing data between forms other than using labels? Seems kind of silly to me, although my label is visible to to the user to they can see the status of autologging



A form is an object based on a class...and you can create your own custom properties for them...can be a good way to pass data without using a control (although using a control does work).

This thread from yesterday, amongst others, has some discussion about forms and custom properties. It's a bit long but if you sift through it you can see how to setup and use a custom property on a form.

Cheers,
Paul
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Click Event Triggering LostFocus on textbox ashley01 General 6 03-05-2004 07:44 AM
TextBox Event jgbarber65 General 6 08-09-2003 04:27 AM
textbox selchange event carma General 2 10-27-2002 12:48 AM
TextBox Event problem!! mms General 3 08-18-2002 09:31 AM
How to run event on data change or cell lostfocus? Dujenwook Word, PowerPoint, Outlook, and Other Office Products 4 09-26-2001 05:57 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->