actually i want to make history of my sofware use...!! and i want to store that history in a textbox. can anyone help me????

Dani AI

Generated

A reliable pattern is: capture the textbox text when the control receives focus (that is the "OLD" value), then compare that saved value with the text when editing finishes (LostFocus, Enter, or a Save button). If they differ, format a single history line (timestamp, old -> new), append it to a multiline history control (or ListBox) and optionally persist it to disk or a database.

A minimal VB6 example (single TextBox + a multiline TextBox used as the visible history):

' module level
Dim prevText As String

Private Sub Text1_GotFocus()
    prevText = Text1.Text
End Sub

Private Sub Text1_LostFocus()
    Dim newText As String
    newText = Text1.Text
    If newText <> prevText Then
        Dim entry As String
        entry = Format(Now, "yyyy-mm-dd hh:nn:ss") & " - from """ & prevText & """ to """ & newText & """"
        AppendToHistory entry
        TextHistory.Text = entry & vbCrLf & TextHistory.Text
        prevText = newText
    End If
End Sub

Sub AppendToHistory(ByVal s As String)
    Dim fn As Integer
    fn = FreeFile
    Open App.Path & "\history.txt" For Append As #fn
    Print #fn, s
    Close #fn
End Sub

Load saved history on startup (Form_Load) by reading the file and prepending lines to the history TextBox. For many textboxes, store each control's previous value in its Tag property or use a control array so the same GotFocus/LostFocus handler works for all.

Notes and cautions:

  • Use LostFocus (or an explicit Save) rather than Change to avoid per-keystroke noise.
  • Programmatic changes also fire events; set a boolean flag when changing .Text in code to avoid recording those.
  • A plain TextBox can become slow or hit limitations for very large logs. For long-term, use a database or append-only file and show only recent lines in the UI.
  • When deploying, pick a writable location for the history file (App.Path is OK during development; on modern Windows use a user-writable folder to avoid permission errors).

This approach addresses runtime capture and simple persistence while keeping the UI history readable and timestamped.

Recommended Answers

All 2 Replies

i don't get what you want exactly

I think you will need database. Or some variables that will hold value at runtime. Jx is right you must explain your idea

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.