REMOTE LOGGING USING WINSOCK ( Visual Basic)
The program below has been tested You don't have to create a beautiful form for it. But you need to run this program while you are away. In other words you need to have a server using some kind of fixed IP. Just place a winsock controll and copy the codes below and paste it in your form.
I don't find it usefull to do the remote logging because my logbook is already in my laptop. If you keep it in the server the program below can help. I choose this methodolgy because it is very much simpler than using Php-MySql or asp-mysql.
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = 0
Me.Left = 0
End Sub
Private Sub Timer1_Timer()
If Winsock1.State <> sckConnected Then
Winsock1.Close
Winsock1.LocalPort = 7000
Winsock1.Listen
End If
End Sub
Private Sub tutup_Click()
End
End Sub
Private Sub Winsock1_Connect()
Me.Caption = "CONNECTED"
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckConnected Then
Winsock1.Close
Winsock1.Accept requestID
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim ayat As String
Winsock1.GetData ayat
Data1.Recordset.AddNew
Label2 = ayat
For i = 1 To Len(ayat)
If Mid(ayat, i, 2) = "X2" Then Data1.Recordset("date") = info: Me.Caption = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X3" Then Data1.Recordset("time") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X4" Then Data1.Recordset("mode") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X5" Then Data1.Recordset("frequency") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X6" Then Data1.Recordset("callsign") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X7" Then Data1.Recordset("name1") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X8" Then Data1.Recordset("his_rst") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "X9" Then Data1.Recordset("my_rst") = info: info = "": i = i + 1: GoTo KEL
If Mid(ayat, i, 2) = "0" Then Data1.Recordset("address1") = info: info = "":
info = info + Mid(ayat, i, 1)
KEL:
Next
Data1.Recordset.Update
Data1.Recordset.MoveLast
End Sub
Now you are away and have a laptop and want to send the data to your log in the
server at home. You can run the program below.
![]() |
Simple eh ?
Simple but if it it works, it workd like magic. |
Private Sub Command1_Click()
Text1.SetFocus
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
If Winsock1.State = sckConnected Then Winsock1.SendData Trim(Text1) + "X2" + Trim(Text2) + "X3" + Trim(Text3) + "X4" + Trim(Text4) + "X5" + Trim(Text5) + "X6" + Trim(Text6) + "X7" +
Trim(Text7) + "X8" + Trim(Text8) + "X9" + Trim(Text9) + "0"
End Sub
' We don't want to leave any textbox empty. So we
place it with ( - ) if it is empty
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text2.SetFocus
End Sub
Private Sub Text1_LostFocus()
If Len(Trim(Text1)) = 0 Then Text1 = "-"
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text3.SetFocus
End Sub
Private Sub Text2_LostFocus()
If Len(Trim(Text2)) = 0 Then Text2 = "-"
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text4.SetFocus
End Sub
Private Sub Text3_LostFocus()
If Len(Trim(Text3)) = 0 Then Text3 = "-"
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text5.SetFocus
End Sub
Private Sub Text4_LostFocus()
If Len(Trim(Text4)) = 0 Then Text4 = "-"
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text6.SetFocus
End Sub
Private Sub Text5_LostFocus()
If Len(Trim(Text5)) = 0 Then Text5 = "-"
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text7.SetFocus
End Sub
Private Sub Text6_LostFocus()
If Len(Trim(Text6)) = 0 Then Text6 = "-"
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text8.SetFocus
End Sub
Private Sub Text7_LostFocus()
If Len(Trim(Text7)) = 0 Then Text7 = "-"
End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Winsock1.State = sckConnected Then Text9.SetFocus
End Sub
Private Sub Text8_LostFocus()
If Len(Trim(Text8)) = 0 Then Text8 = "-"
End Sub
Private Sub Text9_LostFocus()
If Len(Trim(Text9)) = 0 Then Text9 = "-"
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
If Winsock1.State <> sckConnected Then
Winsock1.Close
Winsock1.Connect "127.0.0.1", 7000 ' replace 127.0.0.1 with your domain
End If
End Sub
Private Sub Winsock1_Connect()
Me.Caption = "OK"
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim ayat As String
Winsock1.GetData ayat
Me.Caption = ayat
End Sub
Picture below showing the server side at your home and the client at your laptop. While you are away you can controll your home radio form your mobile unit.
My coding is free and everyone can modify it but don't claim you start and invent everything hi...
![]() ![]() |
||
Client side on your laptop
Private Sub Command1_Click() Private Sub Text3_Change()
|