 |
 |

03-05-2004, 12:53 PM
|
|
Newcomer
|
|
Join Date: Feb 2004
Posts: 9
|
|
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 
|
|

03-05-2004, 01:36 PM
|
 |
Still asleep...
Retired Leader * Expert *
|
|
Join Date: Nov 2003
Location: IronForge
Posts: 2,694
|
|
|
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
|

03-05-2004, 01:47 PM
|
|
Newcomer
|
|
Join Date: Feb 2004
Posts: 9
|
|
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.
|
|

03-05-2004, 01:48 PM
|
|
Senior Contributor
* Expert *
|
|
Join Date: Jul 2003
Posts: 1,300
|
|
|
use Print instead of Write
thingimijig.
|
|

03-05-2004, 02:02 PM
|
|
Newcomer
|
|
Join Date: Feb 2004
Posts: 9
|
|
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 
|
|

03-05-2004, 02:48 PM
|
|
Verbose Coder
Retired Moderator * Guru *
|
|
Join Date: Dec 1999
Location: Phoenix, Arizona
Posts: 3,011
|
|
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
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|