Di sini menerima pembuatan Program Aplikasi, bila anda berminat bisa kontak lewat via Email rizal.lonly@gmail.com, dan bila ada link yang rusak segera hubungi admin, Terima kasih atas kunjungannya.

Script Code : Buat Form Tes Koneksi

Posted on
  • Wednesday, December 14, 2011
  • by
  • Rizal
  • in
  • Labels:
  • Pada artikel kali ini saya akan berbagi tentang Script Code untuk bahasa pemprograman VB (Visual Basic), bisa juga digunakan untuk bahasa pemprograman Java maupun Foxpro, hanya dengan mengganti perintah-perintahnya saja. Script Code yang akan saya bahas adalah tentang Tes Koneksi yaitu koneksi antara Server dan Client, ini bisa digunakan juga untuk Jaringan, bagi anda yang suka mengotak-atik jaringan bisa pakai program ini. Jika anda berminat bisa mengikuti langkah-langkah berikut, anda tinggal mengklik menu dibawah ini :
    1.  Forms
         -  frmConnectionTest(frmConnectionTest.frm)
         -  frmMyIP(frmMyIP.frm)
         -  frmPortScanner(frmPortScanner.frm)
    --------------------------------------------------------------------------------------------------
    1.  Forms
         -  frmConnectionTest
         Script Code :
    Dim AtPort As String
    Dim LimitSend As String
    Dim Start As String
    -----------------------------------------------------------------------------------------
    Private Sub cmdClearLog_Click()
    txtPortsOpenLog.Text = ""
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub CmdScan_Click()
    TimerScanner.Enabled = False
    If Start = "No" Then
    Exit Sub
    End If
    CmdScan.Enabled = False
    If optLocal.Value = True Then
    Dim PortLow As String
    PortLow = txtPortLow.Text
    Dim PortHigh As String
    PortHigh = txtPortHigh.Text
    Dim Ok As String
    Ok = AtPort
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    If Not WinsockPortScanner.State = 7 Then
    WinsockPortScanner.Close
    AtPort = Ok + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    If AtPort = LimitSend Then
    LimitSend = AtPort + 4000
    Exit Sub
    End If
    If AtPort = PortHigh Then
    Exit Sub
    End If
    Call CmdScan_Click
    Exit Sub
    Else
    WinsockPortScanner.Close
    AtPort = Ok + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    If AtPort = PortHigh Then
    Exit Sub
    End If
    Call CmdScan_Click
    End If
    Else
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    TimerScanner.Enabled = True
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdStopRefresh_Click()
    Start = "No"
    TimerRefresh.Enabled = True
    WinsockPortScanner.Close
    CmdScan.Enabled = False
    txtPortHigh.Text = 3000
    txtPortLow.Text = 1
    AtPort = 1
    LimitSend = 4000
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdScanSpeed_Click()
    Dim ScanSpeed As String
    ScanSpeed = txtScanSpeed.Text
    If lblShowsatwhatPort.Caption = "Pada Port: Tidak Terscan" Then
    Else
    MsgBox "Anda harus terlebih dahulu menghentikan scan."
    Exit Sub
    End If
    If ScanSpeed < 1 Then
    MsgBox "Kecepatan harus antara 1-1000"
    Exit Sub
    Else
    GoTo ScanSpeedToHighCheck
    End If
    ScanSpeedToHighCheck:
    If ScanSpeed > 1000 Then
    MsgBox "Kecepatan harus antara 1-1000"
    Exit Sub
    Else
    lblScanSpeed.Caption = "Kecepatan Scan: " & txtScanSpeed.Text
    TimerScanner.Interval = txtScanSpeed.Text
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdSendDataServer_Click()
    If WinsockConnectTest.State = 7 Then
    Dim SendDataServer As String
    SendDataServer = txtSendData.Text
    WinsockConnectTest.SendData SendDataServer
    Else
    Beep
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Command1_Click()
    frmMyIP.Show
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Load()
    Start = "Yes"
    AtPort = 1
    LimitSend = 4000
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Unload(Cancel As Integer)
    If frmPortScanner.Visible = False Then
    Timer1.Enabled = False
    cmdConnnect.Enabled = True
    cmdListen.Enabled = True
    DoEvents
    WinsockConnectTest.Close
    DoEvents
    End
    Else
    Cancel = True
    frmConnectionTest.Visible = False
    Exit Sub
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub TimerRefresh_Timer()
    Start = "Yes"
    lblShowsatwhatPort.Caption = "Pada Port: Tidak Terscan"
    CmdScan.Enabled = True
    TimerRefresh.Enabled = False
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub TimerScanner_Timer()
    Dim Ok As String
    Ok = AtPort
    If Not WinsockPortScanner.State = 7 Then
    WinsockPortScanner.Close
    AtPort = Ok + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    If AtPort = LimitSend Then
    LimitSend = AtPort + 4000
    Exit Sub
    End If
    If AtPort = PortHigh Then
    Exit Sub
    End If
    Call CmdScan_Click
    Exit Sub
    Else
    WinsockPortScanner.Close
    AtPort = Ok + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    If AtPort = PortHigh Then
    Exit Sub
    End If
    Call CmdScan_Click
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub txtPortLow_Change()
    AtPort = txtPortLow.Text
    LimitSend = AtPort + 4000
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockPortScanner_Connect()
    txtPortsOpenLog.SelText = AtPort & vbCrLf
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockPortScanner_Error(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)
    Exit Sub
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdConnnect_Click()
    cmdListen.Enabled = False
    WinsockConnectTest.Close
    WinsockConnectTest.Connect txtIPaddress.Text, txtTestPort
    lblConnectionStatus.Caption = "Koneksi dari " & txtIPaddress.Text & " pada port " & txtTestPort.Text
    Timer1.Enabled = True
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdListen_Click()
    cmdConnnect.Enabled = False
    WinsockConnectTest.Close
    WinsockConnectTest.LocalPort = txtTestPort.Text
    WinsockConnectTest.Listen
    lblConnectionStatus.Caption = "Dengarkan pada port " & txtTestPort.Text
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdCloseConnection_Click()
    cmdConnnect.Enabled = True
    cmdListen.Enabled = True
    WinsockConnectTest.Close
    lblConnectionStatus.Caption = "Koneksi Ditutup"
    Timer1.Enabled = False
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub lblCheckConnection_Click()
    If Not WinsockConnectTest.State = 7 Then
    lblCheckConnection.Caption = "Koneksi: Tidak"
    Else
    lblCheckConnection.Caption = "Koneksi: Ya"
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub lblShowPortScanner_Click()
    frmPortScanner.Show
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Timer1_Timer()
    If Not WinsockConnectTest.State = 7 Then
    lblConnectionStatus.Caption = "Koneksi Gagal"
    WinsockConnectTest.Close
    cmdConnnect.Enabled = True
    cmdListen.Enabled = True
    Timer1.Enabled = False
    Else
    If cmdListen.Enabled = True Then
    lblConnectionStatus.Caption = "Terkoneksi"
    End If
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockConnectTest_Connect()
    lblConnectionStatus.Caption = "Koneksi dari " & txtIPaddress.Text & " pada port " & txtTestPort.Text
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockConnectTest_ConnectionRequest(ByVal requestID As Long)
    If WinsockConnectTest.State <> sckClosed Then WinsockConnectTest.Close
    WinsockConnectTest.Accept requestID
    lblConnectionStatus.Caption = "Host telah terkoneksi..."
    Timer1.Enabled = True
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockConnectTest_DataArrival(ByVal bytesTotal As Long)
    Dim ServerData As String
    WinsockConnectTest.GetData ServerData, vbString
    txtDataServer.SelStart = Len(txtDataServer.Text)
    txtDataServer.SelText = ServerData
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockConnectTest_Error(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)
    Exit Sub
    End Sub
        -  frmMyIP
         Script Code :
    Option Explicit
    -----------------------------------------------------------------------------------------
    Private Sub cmdGetIP_Click()
    On Error GoTo ErrroHere
    Label2.Caption = "Status: Harap tunggu proses pencarian..."
    Dim LengthToIP As Integer
    Dim LengthToEndIP As Integer
    Dim TotalLengthIP As Integer
    Dim FinalIP As String
    Dim Html As String
    Dim HackData As String
    Html = Inet1.OpenURL("http://www.whatismyip.com")
    TotalLengthIP = Len(Html)
    LengthToIP = InStr(1, Html, "is", 1) + 3
    LengthToEndIP = InStr(LengthToIP, Html, " ", 1)
    If LengthToEndIP > 0 Then
    LengthToEndIP = (LengthToEndIP - LengthToIP)
    FinalIP = Mid(Html, LengthToIP, LengthToEndIP)
    HackData = "IP Internal = " & WinsockBot.LocalIP & " <|||> " & "IP Eksternal = " & FinalIP
    Label2.Caption = "Status: IP address ditemukan / Tidak Error"
    Else
    HackData = "Error ketika mencoba untuk mendapatkan IP"
    End If
    text1.Text = HackData
    Exit Sub
    ErrroHere:
    Label2.Caption = "Status: Error untuk menemukan IP Eksternal"
    HackData = "IP Internal = " & WinsockBot.LocalIP & " <|||> " & "IP Eksternal = Pencarian-Error"
    End Sub
        -  frmPortScanner
    Script Code :
    Dim AtPort As String
    Dim Start As String
    Dim Pause As Boolean
    -----------------------------------------------------------------------------------------
    Private Sub cmdClearLog_Click()
    txtPortsOpenLog.Text = ""
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdPause_Click()
    If cmdPause.Caption = "Pause" Then
    cmdPause.Caption = "Lanjutkan"
    Pause = True
    Else
    cmdPause.Caption = "Pause"
    Pause = False
    Call CmdScan_Click
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub CmdScan_Click()
    Dim PortLow As String
    PortLow = txtPortLow.Text
    Dim PortHigh As String
    PortHigh = txtPortHigh.Text
    TimerScanner.Enabled = False
    If Pause = True Then
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort & " Pause"
    Exit Sub
    End If
    If Start = "No" Then
    Exit Sub
    End If
    If AtPort = PortHigh Then
    Exit Sub
    End If
    CmdScan.Enabled = False
    If optLocal.Value = True Then
    Do
    If Start = "No" Then
    Exit Sub
    End If
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    If Not WinsockPortScanner.State = 7 Then
    WinsockPortScanner.Close
    AtPort = AtPort + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    Else
    WinsockPortScanner.Close
    AtPort = AtPort + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    End If
    Loop Until AtPort = PortHigh
    Else
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    TimerScanner.Enabled = True
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdStopRefresh_Click()
    Start = "No"
    TimerRefresh.Enabled = True
    WinsockPortScanner.Close
    CmdScan.Enabled = False
    txtPortHigh.Text = 3000
    txtPortLow.Text = 1
    AtPort = 1
    LimitSend = 4000
    cmdPause.Caption = "Pause"
    Pause = False
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmdScanSpeed_Click()
    Dim ScanSpeed As String
    ScanSpeed = txtScanSpeed.Text
    If lblShowsatwhatPort.Caption = "Pada Port: Tidak Terscan" Then
    Else
    MsgBox "Anda harus terlebih dahulu menghentikan scan saat ini."
    Exit Sub
    End If
    If ScanSpeed < 1 Then
    MsgBox "Kecepatan harus antara 1-1000"
    Exit Sub
    Else
    GoTo ScanSpeedToHighCheck
    End If
    ScanSpeedToHighCheck:
    If ScanSpeed > 1000 Then
    MsgBox "Kecepatan harus antara 1-1000"
    Exit Sub
    Else
    lblScanSpeed.Caption = "Kecepatan Scan: " & txtScanSpeed.Text
    TimerScanner.Interval = txtScanSpeed.Text
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Load()
    Start = "Yes"
    AtPort = 1
    LimitSend = 4000
    Pause = False
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Unload(Cancel As Integer)
    If frmConnectionTest.Visible = False Then
    TimerRefresh.Enabled = False
    TimerScanner.Enabled = False
    WinsockPortScanner.Close
    End
    Else
    Cancel = True
    frmPortScanner.Visible = False
    Exit Sub
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub lblShowConnectionTest_Click()
    frmConnectionTest.Show
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub TimerRefresh_Timer()
    Start = "Yes"
    lblShowsatwhatPort.Caption = "Pada Port: Tidak Terscan"
    CmdScan.Enabled = True
    TimerRefresh.Enabled = False
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub TimerScanner_Timer()
    If Pause = True Then
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort & " Pause"
    TimerScanner.Enabled = False
    Exit Sub
    End If
    If Start = "No" Then
    TimerScanner.Enabled = False
    Exit Sub
    End If
    If AtPort = PortHigh Then
    Exit Sub
    End If
    If Not WinsockPortScanner.State = 7 Then
    WinsockPortScanner.Close
    AtPort = AtPort + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    Exit Sub
    Else
    WinsockPortScanner.Close
    AtPort = AtPort + 1
    lblShowsatwhatPort.Caption = "Pada port: " & AtPort
    If AtPort = PortHigh Then
    Exit Sub
    End If
    WinsockPortScanner.Close
    DoEvents
    WinsockPortScanner.Connect txtIPHostscanner.Text, AtPort
    DoEvents
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub txtPortLow_Change()
    AtPort = txtPortLow.Text
    LimitSend = AtPort + 4000
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockPortScanner_Connect()
    txtPortsOpenLog.SelStart = Len(txtPortsOpenLog.Text)
    txtPortsOpenLog.SelText = AtPort & vbCrLf
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub WinsockPortScanner_Error(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)
    Exit Sub
    End Sub
    Sekian dulu informasi dari saya, bila ada pertanyaan bisa lewat kotak komentar.
    Terima kasih, semoga bermanfaat!

    Baca Juga Artikel Terkait :

     
    Copyright © 2011 - 2012 Blogger templates by Rizal