Showing posts with label VB 6. Show all posts
Showing posts with label VB 6. Show all posts

Menghitung Jumlah Hari Dalam Satu Bulan Pada Visual Basic

Source code berikut untuk menghitung jumlah hari dalam satu bulan pada Visual Basic.

Buat 1 project dengan :
1 Form
1 CommandButton

Copy source code berikut pada Form :

Public Function LastDayOfMonth(ByVal ValidDate As Date) As Byte
Dim LastDay As Byte
LastDay = DatePart("d", DateAdd("d", -1, DateAdd("m", 1, _
DateAdd("d", -DatePart("d", ValidDate) + 1, _
ValidDate))))
LastDayOfMonth = LastDay
End Function

Private Sub Command1_Click()
MsgBox "Jumlah hari pada bulan ini adalah " & LastDayOfMonth(Now) & " hari"
End Sub




Download Source Code
Read More...

Script Koneksi MySQL Dengan Visual Basic 6

Source code berikut untuk mengoneksikan MySQL dengan VB 6. Menggunakan MySQL ODBC 3.51 Driver sebagai penghubung antara VB dan MySQL nya.

Simpan source code berikut di Module :

Public Conn As New ADODB.Connection

Public Sub koneksi()
Dim ConnString As String
Dim db_name As String
Dim db_server As String
Dim db_port As String
Dim db_user As String
Dim db_pass As String

On Error GoTo buat_koneksi_Error

db_name = "honorer" 'nama database anda
db_server = "localhost" 'server database anda
db_port = "3306"
db_user = "root" 'username db anda
db_pass = "" 'isi jika db anda menggunakan password

'ganti DRIVER berikut menjadi {MySQL ODBC 5.1 Driver} jika ODBC yang anda gunakan versi 5.1
ConnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_user & ";PWD=" & db_pass & ";PORT=" & db_port & ";OPTION=3"

If Conn.State = 1 Then Conn.Close
With Conn
.ConnectionString = ConnString
.Open
End With

On Error GoTo 0
Exit Sub

buat_koneksi_Error:
MsgBox "Ada kesalahan dengan server, periksa apakah server sudah berjalan !", vbInformation, "Cek Server"
End Sub

Untuk pemanggilannya, gunakan pada setiap event Form_Load

Private Sub Form_Load()
koneksi
End Sub

Jika membutuhkan ADODB Connection, gunakan variabel ‘Conn’ seperti contoh berikut :

rsAdo.Open "select * from tabel", Conn


Read More...
  • Mahasiswa STMIK Duta Bangsa
  • description
  • description
  • description
  • description
  • description
  • description
  • description

Free Hosting

Free Hosting

My Blog List

A
B
C
     
D
E
F
DuGMp3    
G
H
I
Goo Otomotif HouseofScript  
J
K
L
Java Hotline    
M
N
O

My Games Collection

MeLangKah LeBih MaJu

   
P
Q
R
Pamella Decoration    
S
T
U
Studied WaLL    
V
W
X
     
Y
Z
0-9
     









Join....!


Free Domain

Free Domain

SiNyO. Powered by Blogger.