Hi, all
I have an application that listen to a port, and receives UDP data. The data is sent to a textbox.
I want to add a checkbox, and when the checkbox is =1 then I want the UDP data to be saved to a file on desktop with date and time.
Thank's

I made this code, and it does the job. But it doesn't make a new file when I check and uncheck the checkbox. I can only make one log, then I need to restart my program, to make a new log.

Private Sub sckUDP_DataArrival(ByVal bytesTotal As Long)

On Error Resume Next
If Err Then MsgBox Error$, 48
Dim filelocation As String
Dim strData As String

sckUDP.GetData strData 'Retrieve the data
txtReceive.Text = strData 'Display it

If chkLog = 1 Then
filelocation = "UDP_Log" & "-" & Format(Now, "yyyymmdd hhmmss") & ".txt"
Open filelocation For Append As #1
Print #1, txtReceive.Text
If chkLog = 0 Then
Close #1

End If
End If

End Sub