Bagi sobat - sobat yang tertarik silahkan ikuti langkah - langkah pembuatan coding nya dibawah ini
Ketik codding dibawah ini pada module Project
Option Explicit
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As _
String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Function WriteIniFile(ByVal sIniFileName As String, ByVal sSection As String, ByVal sItem As String, ByVal sText As String) As Boolean
Dim i As Integer
On Error GoTo sWriteIniFileError
i = WritePrivateProfileString(sSection, sItem, sText, sIniFileName)
WriteIniFile = True
Exit Function
sWriteIniFileError:
WriteIniFile = False
End Function
Function ReadIniFile(ByVal sIniFileName As String, ByVal sSection As String, ByVal sItem As String, ByVal sDefault As String) As String
Dim iRetAmount As Integer
Dim sTemp As String
sTemp = String$(50, 0)
iRetAmount = GetPrivateProfileString(sSection, sItem, sDefault, sTemp, 50, sIniFileName)
sTemp = Left$(sTemp, iRetAmount)
ReadIniFile = sTemp
End Function
'Contoh Menyimpan User Logon
Public Function SetUserLogon(Tanggal As String)
WriteIniFile App.Path & "\Config.ini", "LOGIN", "Logon", Tanggal
End Sub
'Contoh Mengambil info User Logon
Public Function GetUserLogon () As String
GetUserLogon = ReadIniFile(App.Path & "\Config.ini", "LOGIN", "Logon", "")
End Sub
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As _
String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Function WriteIniFile(ByVal sIniFileName As String, ByVal sSection As String, ByVal sItem As String, ByVal sText As String) As Boolean
Dim i As Integer
On Error GoTo sWriteIniFileError
i = WritePrivateProfileString(sSection, sItem, sText, sIniFileName)
WriteIniFile = True
Exit Function
sWriteIniFileError:
WriteIniFile = False
End Function
Function ReadIniFile(ByVal sIniFileName As String, ByVal sSection As String, ByVal sItem As String, ByVal sDefault As String) As String
Dim iRetAmount As Integer
Dim sTemp As String
sTemp = String$(50, 0)
iRetAmount = GetPrivateProfileString(sSection, sItem, sDefault, sTemp, 50, sIniFileName)
sTemp = Left$(sTemp, iRetAmount)
ReadIniFile = sTemp
End Function
'Contoh Menyimpan User Logon
Public Function SetUserLogon(Tanggal As String)
WriteIniFile App.Path & "\Config.ini", "LOGIN", "Logon", Tanggal
End Sub
'Contoh Mengambil info User Logon
Public Function GetUserLogon () As String
GetUserLogon = ReadIniFile(App.Path & "\Config.ini", "LOGIN", "Logon", "")
End Sub
Nah sekarang tinggal dimasukan kedalam Project fungsi - fungsi tersebut misal pada saat form diload coding nya seperti dibawah ini
Private Sub Form_Load()
'Mengambil Info User Logon
Label1.Caption = GetUserLogon
'Menyimpan User Logon
call SetUserLogon(Format(Date, "dddd, dd mmm yyyy") & " " & Time)
End Sub
'Mengambil Info User Logon
Label1.Caption = GetUserLogon
'Menyimpan User Logon
call SetUserLogon(Format(Date, "dddd, dd mmm yyyy") & " " & Time)
End Sub
Cukup sekian dulu tutorial kali ini dan kalau ada waktu akan saya sambung pada tutorial berikutnya, mudah - mudahan ada mamfaatnya bagi kita semua dan VB Depelover khususnya
Tidak ada komentar:
Posting Komentar