Berikut ini adalah Source codenya. Langsung saja yang dibutuhkan dalam pembuatan aplikasi ini adalah :
- 2 label dengan property name LblCekMyIP1 dan LblCekMyIP2
- 1 timer dengan property name Timer1, iNTERVAL = 1000
- Winsock1, untuk menambahkan Winsock1 pada toolbox maka dengan cara klik kanan pada toolbox pilih component dan centang microsoft winsock control 6.0
- status bar dengan property name SB, untuk menambahkan status bar pada toolbox caranya sama dengan winsock tetapi pilih windows common controls 6.0(sp6) Kemudian setelah status bar ditambahkan dalam form maka klik kanan status bar tersebut pilih property dan pada tab panel pilih angka 2 pada textbox Autosize.
- 1 modul untuk source code cek koneksi internet dan ip adress/Host name- 1 form
Semoga bermanfaat, terimakasih.
- 1 timer dengan property name Timer1, iNTERVAL = 1000
- Winsock1, untuk menambahkan Winsock1 pada toolbox maka dengan cara klik kanan pada toolbox pilih component dan centang microsoft winsock control 6.0
- status bar dengan property name SB, untuk menambahkan status bar pada toolbox caranya sama dengan winsock tetapi pilih windows common controls 6.0(sp6) Kemudian setelah status bar ditambahkan dalam form maka klik kanan status bar tersebut pilih property dan pada tab panel pilih angka 2 pada textbox Autosize.
- 1 modul untuk source code cek koneksi internet dan ip adress/Host name- 1 form
Semoga bermanfaat, terimakasih.
========================================
'COPY PASTEKAN KODE DI BAWAH INI PADA FORM
========================================
Private Sub Form_Load()
Timer1.Enabled = True
LblCekMyIP1 = "IP Host Name: " & GetIPHostName
LblCekMyIP2 = "IP Address: " & GetIPAddress()
End Sub
Private Sub Timer1_Timer()
If InternetGetConnectedState(0&, 0&) = 1 Then
SB.Panels(1).Text = "Status: Terhubung dengan Internet"
Else
SB.Panels(1).Text = "Status: Tidak terhubung dengan Internet"
End If
End Sub
=============================
Letakkan code di bawah Ini pada Modul
=============================
'cek koneksi internet
Public Declare Function Internet
GetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
'---------CEK IP Adress komputer dan HOST NAME-----
Public Const MAX_WSADescription = 256Public Const MAX_WSASYSStatus = 128'
Public Const ERROR_SUCCESS As Long = 0
Public Const WS_VERSION_REQD As Long = &H101
Public Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Public Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Public Const MIN_SOCKETS_REQD As Long = 1Public Const SOCKET_ERROR As Long = -1
Public Type HostenthName As LonghAliases As LonghAddrType As IntegerhLen As IntegerhAddrList As Long
End Type
Public Type WSADATAwversion As IntegerwHighVersion As IntegerszDescription(0 To MAX_WSADescription) As ByteszSystemStatus(0 To MAX_WSASYSStatus) As BytewMaxSockets As IntegerwMaxUDPDG As IntegerdwVendorInfo As Long
End Type
Public Declare Function WSAGetlastError Lib "wsock32.dll" () As Long
Public Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequired As Long, lpWSAdata As WSADATA) As Long
Public Declare Function WSACleanup Lib "wsock32.dll" () As Long
Public Declare Function gethostname Lib "wsock32.dll" (ByVal szHost As String, ByVal dwHostLen As Long) As Long
Public Declare Function GetHostByName Lib "wsock32.dll" Alias "gethostbyname" (ByVal szHost As String) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvdest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Public Function GetIPAddress() As String
Dim sHostName As String * 256
Dim lpHost As Long
Dim HOST As Hostent
Dim dwIPAddr As Long
Dim tmpIPAddr() As Byte
Dim i As Integer
Dim sIPAddr As String
If Not SocketsInitialize() Then
GetIPAddress = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPAddress = ""MsgBox "Windows Sockets Error " & Str$(WSAGetlastError()) & " has occurred. Host Name tidak dapat ditampilkan."SocketsCleanup
Exit Function
End If
sHostName = Trim$(sHostName)
lpHost = GetHostByName(sHostName)
If lpHost = 0 Then
GetIPAddress = "" MsgBox "Socket Windows tidak memberikan respon. " & "Host Name tidak dapat ditampilkan." SocketsCleanup
Exit Function
End If
CopyMemory HOST, lpHost, Len(HOST)CopyMemory dwIPAddr, HOST.hAddrList, 4ReDim tmpIPAddr(1 To HOST.hLen)CopyMemory tmpIPAddr(1), dwIPAddr, HOST.hLenFor i = 1 To HOST.hLensIPAddr = sIPAddr & tmpIPAddr(i) & "."NextGetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)SocketsCleanup
End Function
Public Function GetIPHostName() As StringDim sHostName As String * 256If Not SocketsInitialize() ThenGetIPHostName = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR ThenGetIPHostName = ""MsgBox "Windows Sockets Error " & Str$(WSAGetlastError()) & " has occurred. Host Name tidak dapat ditampilkan."SocketsCleanup
Exit Function
End IfGetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)SocketsCleanup
End Function
Public Function HiByte(ByVal wParam As Integer)HiByte = wParam \ &H100 And &HFF&
End Function
Public Function LoByte(ByVal wParam As Integer)LoByte = wParam And &HFF&
End Function
Public Sub SocketsCleanup() If WSACleanup() <> error_success_ Then MsgBox " Socket Error terjadi dalam CleanUp."
End If
End Sub
Public Function SocketsInitialize() As Boolean
Dim WSAD As WSADATA
Dim sLoByte As String
Dim sHiByte As StringIf WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS ThenMsgBox "Socket Windows 32-bit tidak respon"SocketsInitialize = False
Exit Function
End If
If WSAD.wMaxSockets = MIN_SOCKETS_REQD Then MsgBox "Aplikasi ini membutuhkan minimum " & CStr(MIN_SOCKETS_REQD) & " Socket yang support." SocketsInitialize = False
Exit Function
End If
If LoByte(WSAD.wversion) < shibyte =" CStr(HiByte(WSAD.wversion))" slobyte =" CStr(LoByte(WSAD.wversion))MsgBox" socketsinitialize =" False">
'COPY PASTEKAN KODE DI BAWAH INI PADA FORM
========================================
Private Sub Form_Load()
Timer1.Enabled = True
LblCekMyIP1 = "IP Host Name: " & GetIPHostName
LblCekMyIP2 = "IP Address: " & GetIPAddress()
End Sub
Private Sub Timer1_Timer()
If InternetGetConnectedState(0&, 0&) = 1 Then
SB.Panels(1).Text = "Status: Terhubung dengan Internet"
Else
SB.Panels(1).Text = "Status: Tidak terhubung dengan Internet"
End If
End Sub
=============================
Letakkan code di bawah Ini pada Modul
=============================
'cek koneksi internet
Public Declare Function Internet
GetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
'---------CEK IP Adress komputer dan HOST NAME-----
Public Const MAX_WSADescription = 256Public Const MAX_WSASYSStatus = 128'
Public Const ERROR_SUCCESS As Long = 0
Public Const WS_VERSION_REQD As Long = &H101
Public Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Public Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
Public Const MIN_SOCKETS_REQD As Long = 1Public Const SOCKET_ERROR As Long = -1
Public Type HostenthName As LonghAliases As LonghAddrType As IntegerhLen As IntegerhAddrList As Long
End Type
Public Type WSADATAwversion As IntegerwHighVersion As IntegerszDescription(0 To MAX_WSADescription) As ByteszSystemStatus(0 To MAX_WSASYSStatus) As BytewMaxSockets As IntegerwMaxUDPDG As IntegerdwVendorInfo As Long
End Type
Public Declare Function WSAGetlastError Lib "wsock32.dll" () As Long
Public Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequired As Long, lpWSAdata As WSADATA) As Long
Public Declare Function WSACleanup Lib "wsock32.dll" () As Long
Public Declare Function gethostname Lib "wsock32.dll" (ByVal szHost As String, ByVal dwHostLen As Long) As Long
Public Declare Function GetHostByName Lib "wsock32.dll" Alias "gethostbyname" (ByVal szHost As String) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvdest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Public Function GetIPAddress() As String
Dim sHostName As String * 256
Dim lpHost As Long
Dim HOST As Hostent
Dim dwIPAddr As Long
Dim tmpIPAddr() As Byte
Dim i As Integer
Dim sIPAddr As String
If Not SocketsInitialize() Then
GetIPAddress = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR Then
GetIPAddress = ""MsgBox "Windows Sockets Error " & Str$(WSAGetlastError()) & " has occurred. Host Name tidak dapat ditampilkan."SocketsCleanup
Exit Function
End If
sHostName = Trim$(sHostName)
lpHost = GetHostByName(sHostName)
If lpHost = 0 Then
GetIPAddress = "" MsgBox "Socket Windows tidak memberikan respon. " & "Host Name tidak dapat ditampilkan." SocketsCleanup
Exit Function
End If
CopyMemory HOST, lpHost, Len(HOST)CopyMemory dwIPAddr, HOST.hAddrList, 4ReDim tmpIPAddr(1 To HOST.hLen)CopyMemory tmpIPAddr(1), dwIPAddr, HOST.hLenFor i = 1 To HOST.hLensIPAddr = sIPAddr & tmpIPAddr(i) & "."NextGetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)SocketsCleanup
End Function
Public Function GetIPHostName() As StringDim sHostName As String * 256If Not SocketsInitialize() ThenGetIPHostName = ""
Exit Function
End If
If gethostname(sHostName, 256) = SOCKET_ERROR ThenGetIPHostName = ""MsgBox "Windows Sockets Error " & Str$(WSAGetlastError()) & " has occurred. Host Name tidak dapat ditampilkan."SocketsCleanup
Exit Function
End IfGetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)SocketsCleanup
End Function
Public Function HiByte(ByVal wParam As Integer)HiByte = wParam \ &H100 And &HFF&
End Function
Public Function LoByte(ByVal wParam As Integer)LoByte = wParam And &HFF&
End Function
Public Sub SocketsCleanup() If WSACleanup() <> error_success_ Then MsgBox " Socket Error terjadi dalam CleanUp."
End If
End Sub
Public Function SocketsInitialize() As Boolean
Dim WSAD As WSADATA
Dim sLoByte As String
Dim sHiByte As StringIf WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS ThenMsgBox "Socket Windows 32-bit tidak respon"SocketsInitialize = False
Exit Function
End If
If WSAD.wMaxSockets = MIN_SOCKETS_REQD Then MsgBox "Aplikasi ini membutuhkan minimum " & CStr(MIN_SOCKETS_REQD) & " Socket yang support." SocketsInitialize = False
Exit Function
End If
If LoByte(WSAD.wversion) < shibyte =" CStr(HiByte(WSAD.wversion))" slobyte =" CStr(LoByte(WSAD.wversion))MsgBox" socketsinitialize =" False">
Exit Function
End If SocketsInitialize = True
End Function
Bagikan
Belum bisa dipakai, aku coba tidak koneksi statusnya tetap terhubung, padahal aku tidak browsing,tapi aku hanya ada hubungan LAN saja,?
ReplyDeletebenarkah demikian? cara kerjanya ?
This comment has been removed by the author.
ReplyDeleteMaaf baru tahu kalau ada komentar yang masuk, mengenai aplikasi yang ternyata menyatakan "status terhubung dengan internet" padahal tidak terkonek. Saya coba menjawabnya dan bagi yang tahu saya juga ingin jawaban yang lebih pasti, karena ini sudah masuk ke wilayah yang rumit yaitu sistem jaringan.Aplikasi ini mendasarkan pada koneksi windows socket(Winsock) padahal setiap komputer memiliki winsock sendiri-sendiri dalam hardware dan systemnya (winsock control 6.0). Jika ada hubungan local area network (LAN) antara komputer mas dengan komputer lain maka dengan otomatis status bar menyatakan terhubung. Memang seharusnya pernyataan pada status bar menyatakan "Status terhubung dengan Intranet" bukan internet karena hanya dalam local area network saja. Oh ya mas mengenai tidak browsing kok status tetap terhubung, dimungkinkan demikian karena masih adanya winsock komputer mas yang terkonek dengan penyedia layanan misal indosat untuk model modem cdma seperti punya saya.Ini hanya jawaban dari saya yang sangat kurang dan banyak salahnya, saya juga mohon pencerahannya bagi yang tahu pasti jawaban dari pertanyaan tersebut. Untuk masnya saya ucapkan terimakasih karena telah menyempatkan berkomentar dan jika jawaban saya kurang memuaskan dan banyak salah saya minta maaf.
ReplyDeletemas ne buat na pake vb brp n os ap?
ReplyDeleteaku pake os seven ne soal na ><
donload scripnya mohoo8.blogspot.com
ReplyDeletekok error compile error : expected lib
ReplyDeletecara mengatasi laptop cepat panas
ReplyDeletecara memperbaiki cardridge
cara mempercepat koneksi internet
komputer tidak bisa booting
cara mempercepat laptop
cara memperbaiki keyboard laptop
cara menginstall windows 7
Mas tutor juga cara menggandakan uang pakai VB...,, jadi menggunakan array
ReplyDeletecara bikin aplikasi konek internetnya dong bro, biar tambah yahuy....
ReplyDeleteMas Joko inbox source di basyir14u81@gmail.com butuh banget mas
ReplyDeletesaya udah coba masih error di baris
ReplyDeletePublic Type HostenthName As LonghAliases As LonghAddr Type As IntegerhLen As IntegerhAddrList As Long
End Type
Public Type WSADATAwversion As IntegerwHighVersion As IntegerszDescription(0 To MAX_WSADescription) As ByteszSystemStatus(0 To MAX_WSASYSStatus) As BytewMaxSockets As IntegerwMaxUDPDG As IntegerdwVendorInfo As Long
End Type
dan script terakhir di
If LoByte(WSAD.wversion) < shibyte =" CStr(HiByte(WSAD.wversion))" slobyte =" CStr(LoByte(WSAD.wversion))MsgBox" socketsinitialize =" False">
bisa bantu mas joko