
Projemizle lazım olacaklar.
2 tane radiobutton
1 tane label
Gruupbox
1 timer
1 ImList
A
' Kaynak 'www.visualbasicdersleri.com
PHP:
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
If My.Computer.Network.IsAvailable = True Then
LblBagliMi.ForeColor = Color.Green
LblBagliMi.Text = "İnternet AÇIK"
BtnAçKapat.BackgroundImageLayout = ImageLayout.Stretch
BtnAçKapat.Image = ImList.Images("Açık.jpg")
BtnAçKapat.Text = "KAPAT"
Else
LblBagliMi.ForeColor = Color.Red
LblBagliMi.Text = "İnternet KAPALI"
BtnAçKapat.BackgroundImageLayout = ImageLayout.Stretch
BtnAçKapat.Image = ImList.Images("Kapalı.jpg")
BtnAçKapat.Text = "AÇ"
End If
End Sub
Private Sub BtnAçKapat_Click(sender As System.Object, e As System.EventArgs) Handles BtnAçKapat.Click
If RadioButton1.Checked = True Then
Me.Text = "Wireless Bağlantı Seçili"
Else
Me.Text = "ADSL Bağlantı Seçili"
End If
If My.Computer.Network.IsAvailable = True Then
BtnAçKapat.Image = ImList.Images("Kapalı.jpg")
Call nEnable()
Timer1.Start()
Else
BtnAçKapat.Image = ImList.Images("Açık.jpg")
Call nDisable()
Timer1.Start()
End If
End Sub
'Kablolu için Enable (0)
'Kablosuz için Enable (1)
Private Sub nEnable()
LblBagliMi.ForeColor = Color.Red
LblBagliMi.Text = "İnternet KAPALI"
BtnAçKapat.Text = "AÇ" 'www.visualbasicdersleri.com
'disable(devre dışı)
Dim objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Dim colAdapters = objWMIService.Execquery("Select * from Win32_NetworkAdapter Where NetEnabled=True")
colAdapters.ItemIndex(0).Disable()
End Sub
Private Sub nDisable()
'enable (etkin),etkinleştirmek
Windows.Forms.Cursor.Current = Cursors.AppStarting
LblBagliMi.ForeColor = Color.LimeGreen
LblBagliMi.Text = "İnternet AÇIK"
BtnAçKapat.Text = "KAPAT"
Dim objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Dim colAdapters = objWMIService.Execquery("Select * from Win32_NetworkAdapter Where NetEnabled=False")
If RadioButton1.Checked = True Then
colAdapters.ItemIndex(1).Enable() 'kablosuz bağlantı için
End If
If RadioButton2.Checked = True Then
colAdapters.ItemIndex(0).Enable() 'ADSL BAĞLANTI İÇİN
End If
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
If BtnAçKapat.ForeColor = Color.Red Then
BtnAçKapat.ForeColor = Color.White
Else
BtnAçKapat.ForeColor = Color.Red 'www.visualbasicdersleri.com
End If
End Sub
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
Me.Text = "Wireless Bağlantı Seçili"
End Sub
Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
Me.Text = "ADSL Bağlantı Seçili"
End Sub
End Class