0% found this document useful (0 votes)
42 views

Source Code Visual Basic

This document appears to be instructions for a simulation of a queueing system in Visual Basic. It includes code for connecting to a remote host, sending and receiving data, and displaying information like the IP address and hostname. The code has buttons to connect, send data, receive data, disconnect and display information about the connection status and data transfer progress.

Uploaded by

Dendy Nurak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Source Code Visual Basic

This document appears to be instructions for a simulation of a queueing system in Visual Basic. It includes code for connecting to a remote host, sending and receiving data, and displaying information like the IP address and hostname. The code has buttons to connect, send data, receive data, disconnect and display information about the connection status and data transfer progress.

Uploaded by

Dendy Nurak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Tugas 3

Simulasi Sistem Antrian

Nama: Yanuarius Dendy Diktus Nurak

STB : 122285
5
6
Private Sub cmdhostname_Click()
'menampilkan nama host komputer
Dim X As String
X = tcpClient.LocalHostName
MsgBox X
End Sub

Private Sub cmdIP_Click()


' Menampilkan IP komputer
Dim X As String
X = tcpClient.LocalIP
MsgBox X
End Sub

Private Sub Command1_Click()


On Error GoTo ErrHandler

If HostName = vbNullString Then


MsgBox "Enter Remote Host Name First!", vbInformation
Exit Sub
End If

If tcpClient.State = 7 Then
MsgBox "Click Disconnect button first and then connect
", vbExclamation
Exit Sub
End If

' seting IP remote ke server


tcpClient.RemoteHost = tcpClient.LocalIP
'"192.168.100.1"
tcpClient.RemotePort = 1001
tcpClient.Connect

Command1.Enabled = False
Command2.Enabled = True
Command6.Enabled = True

7
ErrHandler:
Exit Sub
End Sub

Private Sub Command2_Click()


Dim a1 As Long, Txt As String, ss As String
If tcpClient.State = 0 Then
MsgBox "Not Conneted", vbExclamation
Exit Sub
End If

If (txtSendData.Text) = vbNullString Then


Label6.Caption = "Please Write a Message First"
Else
'Label6.Caption = "Data send"
'End If
'Txt = txtSendData
ss = tcpClient.LocalHostName
NameSerVer = ss
' tcpClient.SendData ss & ":" & Space(2) &
txtSendData
tcpClient.SendData txtSendData
txtSendData.SetFocus
' Label6.Caption = "Data send"
End If
End Sub

Private Sub Command4_Click()


txtOutput = vbNullString
End Sub

Private Sub Command6_Click()


If tcpClient.State = 0 Then
MsgBox "First click Connect and then disconnect",
vbExclamation
Exit Sub
End If

tcpClient.Close
8
Command1.Enabled = True
Command2.Enabled = False
Command6.Enabled = False
Label6.Caption = "Connection terminated"
End Sub

Private Sub Command7_Click()

End Sub

Private Sub Command8_Click()


If tcpClient.State = 7 Then
Label6.Caption = "Connected to Remote Host"
Else
Label6.Caption = "Not Connected"
End If
Exit Sub
End Sub

Private Sub CommandButton1_Click()


Dim Response As Integer
If tcpClient.State = 7 Then
Response = MsgBox("If you exit your connection to
remote host" & vbCrLf _
& "will be lost. Are you sure to exit(Y/N)", vbYesNo)
If Response = vbYes Then
tcpClient.Close
Unload frmClient
Else
Exit Sub
End If
End If
Unload frmClient
End Sub

Private Sub Form_Load()


Left = (Screen.Width - Width) / 2 ' Center form
horizontally.
Top = (Screen.Height - Height) / 2 ' Center form
vertically.
9
HostName.Text = tcpClient.LocalHostName
End Sub

Private Sub Form_Unload(Cancel As Integer)


Dim Response As Integer, MSG As String
If tcpClient.State = 7 Then
Response = MsgBox("If you exit your connection yo
remote host" & vbCrLf _
& "will be lost. Are you sure to exit(Y/N/C)",
vbQuestion + vbYesNo)
Select Case Response
Case vbNo ' Don't allow close.
Cancel = -1
Exit Sub
MSG = "Connection not terminated."
Case vbYes
tcpClient.Close
Unload frmClient
End Select
' Display message if.
End If

End Sub

Private Sub HostName_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then Command1_Click

End Sub

Private Sub mndurasi_Click()


Dim str As String
Dim Rw As Recordset
str = "select * from waktu"
Set Rw = CoNN.OpenRecordset(str)
If Rw.BOF Then
Exit Sub
Else
DeKoneksi.Commands(2).CommandText = str
LapDurasi.WindowState = 2
LapDurasi.Show 1
10
End If
End Sub

Private Sub mnfclient_Click()


frmClient.Show
End Sub

Private Sub mnkeluar_Click()


Unload Me
End Sub

Private Sub mnreset_Click()


reset_server
End Sub

Private Sub mnsetting_Click()


settings_window.Show
End Sub

Private Sub mntgl_Click()


Dim str As String
Dim Rw As Recordset
str = "select * from nomor order by tanggal"
Set Rw = CoNN.OpenRecordset(str)
If Rw.BOF Then
Exit Sub
Else
DeKoneksi.Commands(1).CommandText = str
LapPertanggal.WindowState = 2
LapPertanggal.Show 1
End If
End Sub

Private Sub tcpClient_Close()


Label6.Caption = "Connection not accepted. Now first
click disconnect" & vbCrLf _
& "button inorder to connect to any remote host on
the network"
Command2.Enabled = False

11
End Sub

Private Sub tcpClient_DataArrival _


(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData
'txtOutput.Text = vbNullString
If frmClient.WindowState = 1 Then
frmClient.WindowState = 0
End If
txtOutput.Text = strData
Command2.Enabled = True
Label6.Caption = "Data Received " & "and " & "Bytes
received: " & bytesTotal
txtSendData.SetFocus
End Sub

Private Sub tcpClient_SendProgress(ByVal bytesSent As


Long, _
ByVal bytesRemaining As Long)
Label6.Caption = "Bytes send: " & bytesSent & vbCrLf _
& "Remaning: " & bytesRemaining

End Sub

You might also like