Pembuatan Module Pada Pemrograman Visual Basic 6.0
2. Tampil kotak dialog klik Open, maka pada project explorer akan tampil Module1
3. Lakukan penyimpanan dengan nama ModKoneksipada folder module directory anda
4. Ketikkan skript berikut pada ModKoneksi
1 | Public conn As ADODB.Connection Public SQL As String Public pemakai As String Public rsGrid As ADODB.Recordset Public rsTampil As ADODB.Recordset Public rsCek As ADODB.Recordset Public rsCombo As ADODB.Recordset Public rsCari As ADODB.Recordset Public rsSimpan As ADODB.Recordset Public rsHapus As ADODB.Recordset | |
2 | Public Sub Main() If App.PrevInstance = True Then MsgBox "Sistem sedang berjalan saat ini.", vbExclamation, "Application Run" Exit Sub End If Set conn = New ADODB.Connection FrmWelcome.Show End Sub | |
Jika anda ingin menambahkan tampilan transparan pada program anda berikut kodenya:
1. Tambahkan satu buah module dan simpan dengan nama ModTransparan
2. Ketikkan script berikut pada ModTransparan :
1 | Option Explicit Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Private Declare Function UpdateLayeredWindow Lib "user32" (ByVal hWnd As Long, ByVal hDCDst As Long, pptDst As Any, psize As Any, ByVal hDCSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, ByVal dwFlags As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const GWL_EXSTYLE = (-20) Private Const LWA_COLORKEY = &H1 Private Const LWA_ALPHA = &H2 Private Const ULW_COLORKEY = &H1 Private Const ULW_ALPHA = &H2 Private Const ULW_OPAQUE = &H4 Private Const WS_EX_LAYERED = &H80000 Public Function isTransparent(ByVal hWnd As Long) As Boolean On Error Resume Next Dim Msg As Long Msg = GetWindowLong(hWnd, GWL_EXSTYLE) If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED Then isTransparent = True Else isTransparent = False End If If Err Then isTransparent = False End If End Function Public Function MakeTransparent(ByVal hWnd As Long, Perc As Integer) As Long Dim Msg As Long On Error Resume Next If Perc < 0 Or Perc > 255 Then MakeTransparent = 1 Else Msg = GetWindowLong(hWnd, GWL_EXSTYLE) Msg = Msg Or WS_EX_LAYERED SetWindowLong hWnd, GWL_EXSTYLE, Msg SetLayeredWindowAttributes hWnd, 0, Perc, LWA_ALPHA MakeTransparent = 0 End If If Err Then MakeTransparent = 2 End If End Function Public Function MakeOpaque(ByVal hWnd As Long) As Long Dim Msg As Long On Error Resume Next Msg = GetWindowLong(hWnd, GWL_EXSTYLE) Msg = Msg And Not WS_EX_LAYERED SetWindowLong hWnd, GWL_EXSTYLE, Msg SetLayeredWindowAttributes hWnd, 0, 0, LWA_ALPHA MakeOpaque = 0 If Err Then MakeOpaque = 2 End If End Function |
Kode ini berfungsi agar tampilan akan muncul dengan otomatis.

Tidak ada komentar