Showing posts with label Visual Basic 6.0. Show all posts
Showing posts with label Visual Basic 6.0. Show all posts

Saturday, March 23, 2013

Thursday, February 28, 2013

[Vb6] Mengetahui Serial ID Cpu

Private Function CpuId() As String
Dim computer As String
Dim wmi As Variant
Dim processors As Variant
Dim cpu As Variant
Dim cpu_ids As String

    computer = "."
    Set wmi = GetObject("winmgmts:" & _
        "{impersonationLevel=impersonate}!\\" & _
        computer & "\root\cimv2")
    Set processors = wmi.ExecQuery("Select * from " & _
        "Win32_Processor")

    For Each cpu In processors
        cpu_ids = cpu_ids & ", " & cpu.ProcessorID
    Next cpu
    If Len(cpu_ids) > 0 Then cpu_ids = Mid$(cpu_ids, 3)

    CpuId = cpu_ids
End Function

Cara ke 2
Command1_Click()
Dim wmiLocator As New WbemScripting.SWbemLocator
    Dim wmiService As WbemScripting.SWbemServices
    Dim wmiProc As WbemScripting.SWbemObject
    '
    'Establish a connection to WMI
    Set wmiService = wmiLocator.ConnectServer
    '
    'Enumerate the processor IDs
    For Each wmiProc In wmiService.InstancesOf("Win32_Processor")
        MsgBox wmiProc.ProcessorID
    Next
End sub


Wednesday, February 27, 2013

Wednesday, February 20, 2013

[Vb6] Filter Adodc dan Datagrid


Masukan kode ini di bawah ini
fungsinya untuk menampilkan text yang di masukan di text box dan hanya itu saja yang keluar ...

If Adodc1.Recordset.RecordCount <> 0 Then 
Adodc1.Recordset.Filter = "Fieldnya '*" & txtcari.Text & "*'" 
Else 
MsgBox "Data tidak Ada!!", vbExclamation 
End If
Cara kedua :

Filter data dengan Textbox
Adodc1.Recordset.Filter = "NamaKolom like '%" + Me.Text1.Text + "%'"
‘jika anda mengetik huruf A maka data-data yang ada huruf A akan di tampilkan


Filter data dengan 2 pencarian textbox
Adodc1.Recordset.Filter = "Kolom1 like '%" + Me.Text1.Text + "%'and Kolom2 like '%" + Me.Text2.Text + "%'"

Wednesday, February 13, 2013

[VB6] Menghitung jumlah item pada listview

 

Buat 1 buah command button dan masukan kode di bawah untuk menghitung jumlah item yang ada pada listview

Private Sub Command1_Click()
Dim i As Integer
Dim Jumlah as string
For i = 1 To ListView1.ListItems.Count '- 1
Jumlah = (ListView1.ListItems(i).Index)  '.SubItems(1))
Next
MsgBox Jumlah
End Sub

Wednesday, August 15, 2012

Membuat TextBox Hanya Menerima Input Huruf/Angka di Visual Basic 6.0 (VB)

 __________________Huruf_________________
Public Sub Huruf(ByRef KeyAscii As Integer)
   If Not (KeyAscii >= Asc("1") & Chr(13) And KeyAscii <= Asc("a") & Chr(13) Or (KeyAscii >= Asc("Z") & Chr(13) And KeyAscii <= Asc("Z") & Chr(13) Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace)) Then
        KeyAscii = 0
    End If
End Sub
Pemakaian :
Private Sub Text1_KeyPress(KeyAscii As Integer)
    Huruf KeyAscii
 End Sub


__________________Angka________________
Public Sub Huruf(ByRef KeyAscii As Integer)
   If Not (KeyAscii >= Asc("1") & Chr(13) And KeyAscii <= Asc("1") & Chr(13) Or (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("Z") & Chr(13) Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace)) Then
        KeyAscii = 0
    End If
End Sub
Pemakaian :
Private Sub Text1_KeyPress(KeyAscii As Integer)
   Huruf KeyAscii
 End Sub

Cara membuat Text/Label kedap kedip visual basic 6.0 (VB)

    Masukan component yang gambar jam beker dulu , lalu langsung masukan kode berikut ini untuk membuat teks/label kedap kedip
Private Sub Timer1_Timer()
If Label1.Visible = True Then 'Label1 ganti dengan nama text/label yang ingin di kedap kedip kan
Label1.Visible = False
Else
Label1.Visible = True
End If
End Sub
label1 adalah teks yang ingin di buat kedap kedip