LINK KE QUIS HARI JUMAT
2. FORM SERVER
LISTING PROGRAM SERVER
Dim xKirim As String
Dim xData1() As String
Dim xData2() As String
Dim xPesan As String
Private Sub form_load()
IPServer = WS.LocalIP
Me.Caption = "Server IP:" & IPServer
Kirim = ""
Pesan = ""
Timer1.Enabled = False
Timer2.Enabled = False
MulaiServer
End Sub
Sub MulaiServer()
WS.LocalPort = 1000
WS.Listen
End Sub
Private Sub Timer1_Timer()
selesai.Value = Format(Now, "HH:mm:ss")
pakai.Value = selesai.Value - mulai.Value
End Sub
Private Sub Timer2_Timer()
WS.SendData "PAKAI-" & pakai.Value & "/" & 3000
End Sub
Private Sub WS_ConnectionRequest(ByVal requestID As Long)
WS.Close
WS.Accept requestID
Me.Caption = "Server-Client" & WS.RemoteHostIP & "Connect"
mulai.Value = Format(Now, "HH:mm:ss")
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Sub CheckData()
xData1 = Split(xKirim, "-")
xData2 = Split(xData1(1), "/")
Select Case xData1(0)
Case "STOP"
Timer1.Enabled = False
Timer2.Enabled = False
End Select
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
WS.GetData xKirim, vbString, bytesTotal
Call CheckData
End Sub
2. FORM CLIENT
LISTING PROGRAM CLIENT
Dim xdata1() As String
Dim xdata2() As String
Dim xkirim As String
Dim IPServer As String
Private Sub cmdConnect_click()
IPServer = "192.168.10.1"
IPClient = ws.LocalIP
ws.Connect IPServer, 1000
End Sub
Private Sub cmddisconnect_Click()
ws.SendData "STOP-XXX"
End Sub
Private Sub form_load()
Me.Caption = "CLIENT IP " & ws.LocalIP
waktu = ""
biaya = ""
End Sub
Sub CheckData()
xdata1() = Split(xkirim, "-")
xdata2() = Split(xdata1(1), "/")
Select Case xdata1(0)
Case "PAKAI":
pakai.Value = xdata2(0)
biaya.Text = xdata2(1)
pemakaian.Text = Val(Hour(pakai.Value)) + Val(Minute(pakai.Value)) * (xdata2(1) / 60)
End Select
End Sub
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
ws.GetData xkirim, vbString, bytesTotal
Call CheckData
End Sub
Tidak ada komentar:
Posting Komentar