Dim ClientIndex As Byte
Dim cRequest As Integer
Dim cData As String
Dim i As Integer
Dim iGD As Integer
Sub MulaiServer()
WS(0).LocalPort = 3000
WS(0).Listen
cRequest = 1
ClientIndex = 1
End Sub
Private Sub Form_Load()
MulaiServer
GD.Rows = 41
For i = 1 To 40
GD.Col = 0
GD.Row = i
GD.Text = i
Next i
iGD = 1
End Sub
Private Sub Timer1_Timer()
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 4
If GD.Text = "START" Then
GD.Col = 3
GD.Text = Time
End If
Next i
End Sub
Private Sub WS_ConnectionRequest(index As Integer, ByVal requestID As Long)
Load WS(cRequest)
WS(cRequest).Close
WS(cRequest).Accept requestID
cRequest = cRequest + 1 '
End Sub
Private Sub WS_DataArrival(index As Integer, ByVal bytesTotal As Long)
WS(index).GetData cData, vbString, bytesTotal
Call CekData(index)
End Sub
Sub CekData(index)
On Error Resume Next
Dim kata() As String
kata = Split(cData, "-")
Select Case kata(0)
Case "START"
GD.Row = iGD
GD.Col = 1
GD.Text = kata(1) 'WS(index).RemoteHostIP
GD.Col = 2
GD.Text = Time
GD.Col = 4
GD.Text = "START"
GD.Col = 5
GD.Text = kata(2)
iGD = iGD + 1
Case "STOP"
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 1
If GD.Text = kata(1) Then
GD.Col = 4
GD.Text = "STOP"
End If
Next i
End Select
End Sub
Private Sub WS_Error(index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
WS(index).Close
End Sub
Listing Program Client
Dim IPS As String
Dim User As String
Private Sub Command1_Click()
ws.SendData “START-” & User & “-ardianto”
End SubPrivate Sub Command2_Click()
ws.SendData “STOP-” & User
End SubPrivate Sub Form_Load()
IPS = “127.0.0.1″
User = ws.LocalIP
ws.Connect IPS, 3000
masuk.Text = “”
keluar = “”
biaya.Text = “”
bayar.Text = “”
End SubSub CheckData()
Dim kata() As String
kata = Split(cData, “-”)
Select Case kata(0)
Case “PAKAI”:
pakai.Value = xdata2(0)
biaya.Text = xdata2(1)
bayar.Text = Val(Hour(pakai.Value)) + Val(Minute(pakai.Value)) * (xkata(1) / 60)
End Select
End SubPrivate Sub ws_DataArrival(ByVal bytesTotal As Long)
ws.GetData xkirim, vbString, bytesTotal
Call CheckData
End SubHasil Program Server
Tidak ada komentar:
Posting Komentar