1. Form her zaman ustte(vb5)
VISUAL BASIC
" Bu vb5 icin gecerlidir. diğer form ustte vb6 icin gecerliydi. ..."
Hepsini Sec'Calışan programınızda yeni bir form acıldığında bunun en 'ustte gorunmesi icin; orn 2 form oluşturun form1_load 'a
'form2.Show ,me
'yazın.
'Bu yontem yalnızca programınızdaki formlar icin gecerlidir. Diğer bir program calıştığında bunun uzerini ortebilir.
'Tum uygulamaların uzerinde kalan bir form
'oluşturmak icin; declare kısmına
Private Declare Function SetWindowPos Lib "user32"
(ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long,
ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long,
ByVal wFlags As Long) As Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
En ustte kalmasını istediğinizde:
SetWindowPos hwnd, _
HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE
Bu ozelliği geri almak icin:
SetWindowPos hwnd, _
HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE
2. İp numaranı gor
VISUAL BASIC
" Winsock nesnesi ile ip numaranı gor ..."
Hepsini Seconcelikle Project>Components yolunu izleyerek acılan pencerenin Controls bolumunden Microsoft Winsock Controls 6.0 (SP6) yi arac kutusuna ekleyin
Forma buton ve winsock nesnesini ekleyin.
Aşağıdaki kodları yazın
Private Sub Command1_Click()
ip = Winsock1.LocalIP
MsgBox ip
End Sub
20****mrcplus****04
3. 3 yazılı ve 3 sozlu notu girilerek ortalama hesabı yapar ..."
Hepsini SecDim kontrol As Integer
Private Sub Command1_Click()
If Text1.Text < 0 Or Text1.Text > 100 Then
MsgBox "yanlış"
ElseIf Text2.Text < 0 Or Text2.Text > 100 Then
MsgBox "yanlış"
ElseIf Text3.Text < 0 Or Text3.Text > 100 Then
MsgBox "yanlış"
ElseIf Text4.Text < 0 Or Text4.Text > 100 Then
MsgBox "yanlış"
ElseIf Text5.Text < 0 Or Text5.Text > 100 Then
MsgBox "yanlış"
ElseIf Text6.Text < 0 Or Text6.Text > 100 Then
MsgBox "yanlış"
End If
Text7.Text = (Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3
Text8.Text = (Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)) / 3
Text9.Text = (Val(Text7.Text) + Val(Text8.Text)) / 2
Select Case Text9.Text
Case 0 To 44
Text10.Text = "CAKTI"
Case Else
Text10.Text = "YIRTTI"
End Select
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
kontrol = MsgBox("CIKMAK İSTEDİĞİNİZE EMİN MİSİNİZ?", vbQuestion + vbYesNo, "Cıkış Formu")
Select Case Control
Case vbYes
End
End Select
End Sub
www.zagaonline.com ' dan Alıntıdır...
1. Forma şifre koyma
VISUAL BASIC 01.07.2003
" Forma şifre koyma ..."
Hepsini Sec'şifre umutyavuz
Private Sub Form_Load()
If InputBox("şifreyi giriniz") "ibrahim ozcicek" Then
MsgBox ("şifreyi bilemediniz.bilgiler uzerinde degişiklik yapamazsınız.")
Text1.Locked = True
End If
End Sub
2. Kayıt programı
VISUAL BASIC
" Kayıt programı ..."
Hepsini Secmodule bolumu
Type kayitbilgisi
adı As String * 20
soyadı As String * 20
sicil As String * 20
cins As String * 20
dep As String * 20
adres As String * 20
tel As String * 20
End Type
Global alanlar As kayitbilgisi
form bolumu
Dim kayitno As Integer
Private Sub Command1_Click()
a = MsgBox("KAYDEDİLSİN Mİ?", 4)
If a = 6 Then
Text1.Text = kayitno
alanlar.adı = Text2.Text
alanlar.soyadı = Text3.Text
alanlar.sicil = Text4.Text
alanlar.adres = Text5.Text
alanlar.tel = Text6.Text
If Option1.Value = True Then
Else
Option2.Value = Option2.Caption
End If
alanlar.dep = Combo1.Text
Put #1, kayitno, alanlar
kayitno = kayitno + 1
Text1.Text = kayitno
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Combo1.Text = ""
Option1.Value = False
Option2.Value = False
Text2.SetFocus
End If
End Sub
Private Sub Command2_Click()
Text1.Text = kayitno
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Combo1.Text = ""
Option1.Value = False
Option2.Value = False
Text2.SetFocus
End Sub
Private Sub Command3_Click()
Close #1
Unload Me
End Sub
Private Sub Form_Activate()
Text2.SetFocus
End Sub
Private Sub Form_Load()
Open "kenan.dat" For Random As #1 Len = Len(alanlar)
kayitno = LOF(1) / Len(alanlar)
kayitno = kayitno + 1
End Sub
3. Paralel port orneği
VISUAL BASIC
" Paralel porta bağlı 8 ledi yakıp sondurmek ..."
Hepsini SecAşağıdaki kodlar tamamen Bana(Emrah Şimşek) aittir. & 90 calışır. Bide bi kac kez irinde havamolsun be hehehee
İlk once 8 led diyotu paralel porta bağlıyoruz nasıl olcak derseniz :-)
paralel portların birer bacağı sırasıyla 2-3-4-5-6-7-8-9 nolu pinlere bağlanır. diğer bacakları ise 18 ile 25 arasınraki pinlerden birine yada teker teker bağlanır.
Daha sonra aşağıdaki kodu module yazıyoruz:
Public Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Bundan sonraki koduda forma yapıştırıyoruz. Ama once
adı led olan 8 buton oluşturulur.
kopyaladıktan sonra evete basarsak daha kolay olur. Yada 8 tane ayrı ayrı cizip adlarını led yapınız.
ve aşağıdaki kodu yapıştırın gitsin.
Private Sub led_Click(Index As Integer)
For i = 0 To 7
led(i).Caption = "Kapalı"
Next
On Local Error Resume Next
Select Case Index
Case 0: Out(888) = 1
Case 1: Out(888) = 2
Case 2: Out(888) = 4
Case 3: Out(888) = 6
Case 4: Out(888) = 16
Case 5: Out(888) = 32
Case 6: Out(888) = 64
Case 7: Out(888) = 128
End Select
led(Index).Caption = "Acık"
End Sub
Tıkladığınız butona ait olan led diyot yanacaktır.
Eğer hepsini kapatmak istersek bi buton koyup click olayına
out(888)=0
hepsini acmak icin ise
out(888)=255
yazarız. Calışması lazım ama calışmazsa İ[email protected] adresine e-mail atın oradn yardımcı olayım
NOT: Bazı bilgisayarlarda portlar kapanmıyor. Yani butun ledler acık kalıyo nedeni pc deki anormallik.
Siz bunun mantığını anlarsanız hoplayan zıplayan kayan , yuruyen ışıklar bile yapabilirsiniz. şimdilik herkese Byes!
1. İnternet kısayolları
VISUAL BASIC
" Aşağıdaki kodları kullanarak kolayca bir kısayol oluşturabilir, uzerine cift tıklayarak web tarayıcınızın ilgili adrese bağlanmasını sağlayabilirsiniz. ..."
Hepsini Sec' Masaustunde zagaonline isimli bir kısayol oluştur
Open "c:\windows\desktop\zagaonline.url" For Output As #1
' Gerekli İceriği yaz
Print #1, "[InternetShortcut]"
' Adresi Yaz
Print #1, "URL=" & "http://www.****************"
Close #1 'Tamamla
2.Acılan Liste
Private Sub Form_Load()
List1.AddItem "pc"
List1.AddItem "mac"
List1.AddItem "mainfrome"
End Sub
Private Sub List1_Click()
If List1.ListIndex = 0 Then
List2.AddItem "winxp,win2000,win98,win2003"
ElseIf List1.ListIndex = 1 Then
List2.AddItem "apple2,apple2.5"
ElseIf List1.ListIndex = 2 Then
List2.AddItem "unix,server,"
End If
3.fiyat listesi
Private Sub Command1_Click()
Dim a, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a + b
End Sub
Private Sub Form_Load()
List1.AddItem "GİGABAYTE"
List1.AddItem "VİA"
List1.AddItem "ASSUS"
List2.AddItem "pentium2"
List2.AddItem "pentium3"
Command1.BackColor = 10000
End Sub
Private Sub List1_Click()
If List1.ListIndex = 0 Then
Text1.Text = "526"
ElseIf List1.ListIndex = 1 Then
Text1.Text = "254"
ElseIf List1.ListIndex = 2 Then
Text1.Text = "622"
End If
End Sub
Private Sub List2_Click()
If List2.ListIndex = 0 Then
Text2.Text = "265"
ElseIf List2.ListIndex = 1 Then
Text2.Text = "121"
End If
End Sub
__________________
vb de en cok kullanılan kodlar...[Guncelenecek] alex_63
Programlama0 Mesaj
●35 Görüntüleme
- ReadBull.net
- Programlama ve Yazılım
- Programlama
- vb de en cok kullanılan kodlar...[Guncelenecek] alex_63