Quiz Online Pemrograman Jaringan No. 3

Ini adalah program yang saya buat dalam Quiz Online No. 3

Untuk melihat Soal No. 3 Quiz Online Hari Jumat : [Klik Disini]

SERVER

Listing Program :

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

 

CLIENT :

 

 

 

 

 

 

 

Listing Program :

Dim IPS As String
Dim User As String

Private Sub Command1_Click()
WS.SendData “START-” & User & “-Fridolin”
End Sub

Private Sub Command2_Click()
WS.SendData “STOP-” & User
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
IPS = “127.0.0.1”
User = WS.LocalIP
WS.Connect IPS, 3000
masuk.Text = “”
keluar = “”
pakai.Text = “”
biaya.Text = “”
End Sub

Sub CheckData()
Dim kata() As String
kata = Split(cData, ” – “)
Select Case kata(0)
Case “PAKAI”:
pakai.Value = xdata2(0)
biaya.Text = xdata2(1)
End Select
End Sub

Private Sub ws_DataArrival(ByVal bytesTotal As Long)
WS.GetData xkirim, vbString, bytesTotal
Call CheckData
End Sub

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: