Senin, 21 Maret 2011

vb scrip

  • Search / Pencarian Pelanggan dengan detail (Faster).
  • Proses Billing Meteran Pelanggan setiap bulannya tidak memerlukan waktu yang lama untuk penginputan.
  • Pengelompokan Tunggakan.
  • Pengeluaran Surat Teguran langsung bagi pelanggan yang menunggak.
  • Pengeluaran Data Cabutan yang telah lewat bulan tunggakan dengan Akurat
  • Pengeluaran SPK (Surat Perintah Kerja) baik Pemutusan atau Pemasangan kembali
  • Output Laporan Pendapatan : Harian, Bulanan dan Tahunan
  • Pengelompokan Laporan Pendapatan sesuai kategori
  • Untuk yang lompat pembayaran bisa di blokir didatabse
  • Beberapa Opsi Untuk pencetakan Rekening seperti Cetak Manual, Collection dll.
  • Laporan data cabutan dan pemasangan kembali dengan akurat
  • Aplikasi Support LAN (Local Area Network) / Jaringan
  • Dan masih banyak yang lain nya.
Beberapa Screen shoot Software TRP




 
 
 
pembuatan label berjalan 
Ketik Coding dibawah ini pada Form Project
 
 
Dim Pos As Integer, StartPos As Integer, Lengh As Integer, iTeks As Integer

Dim MyTeks As String


Private Sub Form_Load()

iTeks = 1

End Sub


Private Sub Timer1_Timer()

Pos = Pos + 1

If iTeks = 1 Then

MyTeks = "Ini adalah Contoh ..."

ElseIf iTeks = 2 Then

MyTeks = "Pembuatan Label Berjalan"

ElseIf iTeks = 3 Then

MyTeks = "Dengan Visual Basic"

End If

StartPos = Len(MyTeks)

Lengh = StartPos - Pos

If Lengh = 0 Then

If iTeks = 1 Then

iTeks = 2

ElseIf iTeks = 2 Then

iTeks = 3

ElseIf iTeks = 3 Then

iTeks = 1

End If

Pos = 0 - StartPos

End If

Label1 = Right(MyTeks, Lengh)

End Sub
 

Persiapan yang dilakukan:

  • Buat Project Baru Standart exe
  • Tambahkan 1 buah TextBox (Text1)
  • Tambahkan 1 buah Label (Label1)
  • Tambahkan 1 Buah CommandButton (Command1) caption : =
'Ketik Coding dibawah ini pada Form Project

Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2

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 Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crColor As Long, ByVal nAlpha As Byte, ByVal dwFlags As Long) As Long

Private Sub Command1_Click()
Dim excel_app As Object
Dim excel_sheet As Object

Set excel_app = CreateObject("Excel.Application")

excel_app.Workbooks.Add
If Val(excel_app.Application.Version) >= 8 Then
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If

excel_sheet.Cells(1, 1) = "=" & Text1.Text

Label1.Caption = excel_sheet.Cells(1, 1)
Label1.Caption = Format$(Label1.Caption, "#,##0")

excel_app.ActiveWorkbook.Close False

excel_app.Quit
Set excel_sheet = Nothing
Set excel_app = Nothing
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1_Click
End Sub
 
  • Buatlah Project Baru Standart Exe
  • Tambahkan 1 buah ComboBox Style : Dropdown Combo
  • Tambahkan 1 buah Module
'Ketik Coding berikut pada Module

Option Explicit

Const CB_FINDSTRING = &H14C

Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Enum EnumKarakter
Asli = 0
Ubah = 1
End Enum

Public Function AutoComplete( _
cbCombo As ComboBox, _
sKeyAscii As Integer, _
Optional bUpperCase As Boolean = True, _
Optional cCharacter As EnumKarakter = Asli) _
As Integer
Dim lngFind As Long, intPos As Integer
Dim intLength As Integer, tStr As String
With cbCombo
If sKeyAscii = 8 Then
If .SelStart = 0 Then Exit Function
.SelStart = .SelStart - 1
.SelLength = 32000
.SelText = ""
Else
intPos = .SelStart
tStr = .Text
If bUpperCase = True Then
.SelText = UCase(Chr(sKeyAscii))
Else
.SelText = (Chr(sKeyAscii))
End If
End If

lngFind = SendMessage(.hwnd, CB_FINDSTRING, 0, _
ByVal .Text)
If lngFind = -1 Then
Exit Function
Else
intPos = .SelStart
intLength = Len(.List(lngFind)) - Len(.Text)
If cCharacter = Ubah Then
.SelText = .SelText & Right(.List(lngFind), _
intLength)
Else
.Text = .List(lngFind)
End If
.SelStart = intPos
.SelLength = intLength
End If
End With
End Function

' Ketik Coding diberikut pada Form

Option Explicit

Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(Combo1, KeyAscii, False, Asli)
End Sub

Private Sub Form_Load()
Call AddData
End Sub

Private Sub AddData()
With Combo1
.Clear
.AddItem "Ana Lestari"
.AddItem "Budi Setiawan"
.AddItem "Eka Syahputra"
.AddItem "Wahyu Perdana"
.AddItem "Blog walking"
.AddItem "Terserah"
End With
End Sub
 
Project Baru Standart EXE tambahkan 1 buah Control CommandButton

Private Sub Command1_Click()
ExitLayout
Unload Me
End Sub

Private Sub ExitLayout()
On Error Resume Next
Dim fHeight As Long
Dim fWidth As Long

For fHeight = Me.Height To 1000 Step -1
Me.Height = fHeight
'Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 3
Next fHeight

If Me.Height = 1000 Then
For fWidth = Me.Width To 1000 Step -2
Me.Width = fWidth
Next fWidth
End If
Me.Refresh
End Sub
 
Option Explicit

Private Sub Form_Load()
Dim i As Integer
Open "C:\test.txt" For Output As #1
Print #1, " --------------------------------"
Print #1, " Create TXT with VB "
Print #1, " --------------------------------"
For i = 1 To 10
Print #1, Space(10) & i & "."
Next i
Print #1, " --------------------------------"
Print #1, " End Of Record"
Print #1, " --------------------------------"
Close #i
Unload Me
End Sub 
 
membuat dan menghapus folder
Ketik Coding Berikut ini pada Module Project


Option Explicit

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

'Fungsi mencek keberadaan folder
Public Function DirectoryExist(DirPath As String) As Boolean
DirectoryExist = Dir(DirPath, vbDirectory) <> ""
End Function

'Fungsi untuk membuat Folder
Public Sub CreateNewDirectory(NewDirectory As String)
Dim sDirTest As String
Dim SecAttrib As SECURITY_ATTRIBUTES
Dim bSuccess As Boolean
Dim sPath As String
Dim iCounter As Integer
Dim sTempDir As String

sPath = NewDirectory

If Right(sPath, Len(sPath)) <> "\" Then
sPath = sPath & "\"
End If

iCounter = 1

Do Until InStr(iCounter, sPath, "\") = 0
iCounter = InStr(iCounter, sPath, "\")
sTempDir = Left(sPath, iCounter)
sDirTest = Dir(sTempDir)
iCounter = iCounter + 1
'create directory
SecAttrib.lpSecurityDescriptor = &O0
SecAttrib.bInheritHandle = False
SecAttrib.nLength = Len(SecAttrib)
bSuccess = CreateDirectory(sTempDir, SecAttrib)
Loop
End Sub

'Fungsi Untuk Menghapus folder
Public Sub DelDirectory(sName as String)
On Error Resume Next
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
If Dir(sName, vbDirectory) <> "" Then
Fso.DeleteFolder sName
End If
Set Fso = Nothing
 
membuat form transparan


Bagaimana dengan Codingnya ikuti Langkah - Langkah Berikut :

  • Buat Project Baru Standart Exe
Ketik Coding dibawah ini pada Form Project Sobat

Option Explicit

Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2

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 Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crColor As Long, ByVal nAlpha As Byte, ByVal dwFlags As Long) As Long

Private Sub Form_Load()
Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(Me.hwnd, RGB(255, 0, 255), 128, LWA_ALPHA Or LWA_COLORKEY)
End Sub
 
menampilkan angka terbilang pada vb
Persiapan yang dilakukan
  • Buat Project Baru Standart Exe
  • Tambahkan 1 buah TextBox dan 1 Label
  • Tambahkan 1 buah Module

’Ketik Coding dibawah ini pada module

Option Explicit

Public Const vbKeyDecPt = 46
Public Function ConvertirEnText(ValNum As Double) As String

Static Unites(0 To 9) As String
Static Dixaines(0 To 9) As String
Static LesDixaines(0 To 9) As String
Static Milliers(0 To 4) As String

Dim i As Integer
Dim nPosition As Integer
Dim ValNb As Integer
Dim LesZeros As Integer
Dim strResultat As String
Dim strTemp As String
Dim tmpBuff As String

Unites(0) = "nol"
Unites(1) = "satu"
Unites(2) = "dua"
Unites(3) = "tiga"
Unites(4) = "empat"
Unites(5) = "lima"
Unites(6) = "enam"
Unites(7) = "tujuh"
Unites(8) = "delapan"
Unites(9) = "sembilan"

Dixaines(0) = "sepuluh"
Dixaines(1) = "sebelas"
Dixaines(2) = "dua belas"
Dixaines(3) = "tiga belas"
Dixaines(4) = "empat belas"
Dixaines(5) = "lima belas"
Dixaines(6) = "enam belas"
Dixaines(7) = "tujuh belas"
Dixaines(8) = "delapan belas"
Dixaines(9) = "sembilan belas"

LesDixaines(0) = ""
LesDixaines(1) = "sepuluh"
LesDixaines(2) = "dua puluh"
LesDixaines(3) = "tiga puluh"
LesDixaines(4) = "empat puluh"
LesDixaines(5) = "lima puluh"
LesDixaines(6) = "enam puluh"
LesDixaines(7) = "tujuh puluh"
LesDixaines(8) = "delapan puluh"
LesDixaines(9) = "sembilan puluh"

Milliers(0) = ""
Milliers(1) = "ribu"
Milliers(2) = "juta"
Milliers(3) = "milyard"
Milliers(4) = "triliyun"

On Error GoTo NbVersTexteError

strTemp = CStr(Int(ValNum)) 'Untuk Konversi Angka yang di format ke default

For i = Len(strTemp) To 1 Step -1
ValNb = Val(Mid$(strTemp, i, 1))
nPosition = (Len(strTemp) - i) + 1
Select Case (nPosition Mod 3)
Case 1
LesZeros = False
If i = 1 Then
If ValNb > 1 Then
tmpBuff = Unites(ValNb) & " "
Else
tmpBuff = ""
End If
ElseIf Mid$(strTemp, i - 1, 1) = "1" Then
tmpBuff = Dixaines(ValNb) & " "
i = i - 1
ElseIf ValNb > 0 Then
tmpBuff = Unites(ValNb) & " "
Else
LesZeros = True
If i > 1 Then
If Mid$(strTemp, i - 1, 1) <> "0" Then
LesZeros = False
End If
End If
If i > 2 Then
If Mid$(strTemp, i - 2, 1) <> "0" Then
LesZeros = False
End If
End If
tmpBuff = ""
End If
If LesZeros = False And nPosition > 1 Then
tmpBuff = tmpBuff & Milliers(nPosition / 3) & " "
End If
strResultat = tmpBuff & strResultat
Case 2
If ValNb > 0 Then
strResultat = LesDixaines(ValNb) & " " & _
strResultat
End If
Case 0
If ValNb > 0 Then
If ValNb > 1 Then
strResultat = Unites(ValNb) & " ratus " & _
strResultat
Else
strResultat = "seratus " & strResultat
End If
End If
End Select
Next i
If Len(strResultat) > 0 Then
strResultat = UCase$(Left$(strResultat, 1)) & _
Mid$(strResultat, 2)
End If

EndNbVersTexte:
ConvertirEnText = strResultat & " rupiah"
Exit Function

NbVersTexteError:
strResultat = "Une Erreur !"
Resume EndNbVersTexte
End Function

Public Function AngkaTerbilang(Counter As Double) As String
On Error Resume Next
Dim A As Single
AngkaTerbilang = ConvertirEnText(Counter)
A = Len(ConvertirEnText(Counter))
If Mid(ConvertirEnText(Counter), 1, 4) = "Ribu" Then
AngkaTerbilang = "Se" + Mid(ConvertirEnText(Counter), 1, A)
End If
If Mid(ConvertirEnText(Counter), 1, 4) = "Juta" Then
AngkaTerbilang = "Satu " + Mid(ConvertirEnText(Counter), 1, A)
End If
If Mid(ConvertirEnText(Counter), 1, 7) = "" Then
AngkaTerbilang = "Satu " + Mid(ConvertirEnText(Counter), 1, A)
End If
If Mid(ConvertirEnText(Counter), 1, 7) = "Milyard" Then
AngkaTerbilang = "Satu " + Mid(ConvertirEnText(Counter), 1, A)
End If
End Function

’Ketik Coding dibawah ini pada Form

Option Explicit

Private Sub Text1_Change()
If Text1 <> "" Then
Text1.Text = Format(Text1, "#,##0")
Text1.SelStart = Len(Text1)
Label1.Caption = AngkaTerbilang(Text1)
Label1.Caption = StrConv(Label1, vbProperCase)
Else
Label1.Caption = ""
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = vbKeyDecPt Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub
 
 

persiapan yang dilakukan :
  • Buatlah Project Baru (Standard exe)
  • Tambahkan :
  • 3 Label
  • Label1 (Caption : Mencari Selisih Tanggal)
  • Label2 (Caption : Lahir :)
  • Label3 (Caption : Umur Anda)
  • 1 Buah Frame ------> Caption : Masukan Tanggal Lahir
  • 3 Buah ComboBox ----> Style : 2 - Dropdown List
  • 1 Buah Command Button
yang kurang lebih penampakannya seperti gambar dibawah ini



kemudian ketik Coding dibawah ini pada Form

Option Explicit

Private Sub showTanggal()
Dim i As Byte
For i = 1 To 31
Combo1.AddItem Format(i, "00")
Next i
Combo1.ListIndex = 0
End Sub

Private Sub showBulan()
Dim i As Byte
For i = 1 To 12
Combo2.AddItem Format(i, "00")
Next i
Combo2.ListIndex = 0
End Sub

Private Sub showTahun()
Dim i As Integer
For i = 1950 To Year(Now)
Combo3.AddItem i
Next i
Combo3.ListIndex = 0
End Sub

Private Sub Command1_Click()
Dim sLahir As String
sLahir = Combo1 + "/" + Combo2 + "/" + Combo3
If IsDate(sLahir) = True Then
Label3.Caption = "Umur anda sekarang : " & SelisihTanggal(CDate(sLahir), Date)
Else
MsgBox "Tanggal nya salah coy", 48, "Info"
Combo1.SetFocus
End If
End Sub

Private Sub Form_Load()
showTanggal
showBulan
showTahun
End Sub

Private Function SelisihTanggal(ByVal TanggalAwal As _
Date, ByVal TanggalAkhir As Date) As String

Dim Tahun As Integer, Sisa As Integer
Dim SelisihBulan As Integer
On Error GoTo pesan
SelisihBulan = DateDiff("m", TanggalAwal, TanggalAkhir)
Tahun = SelisihBulan \ 12
Sisa = SelisihBulan Mod 12
SelisihTanggal = Tahun & " Tahun " & Sisa & " Bulan"
Exit Function
pesan:
MsgBox "Tipe Tanggal Salah!", vbCritical, "Error TAnggal"
End Function
 
 
Buatlah Project baru (Standard Exe)

Tambahkan Microsoft DAO 3.6 Object Library dengan cara click menu Project > References … cari dan pilih Microsoft DAO 3.6 Object Library

Tambahkan 1 module

'Ketik coding berikut pada Module

Option Explicit
Public DbLokasi As String
Public DbNama As String

Public Function CreateDB()
Dim DTB As Database
Dim Tabel As TableDef

Screen.MousePointer = vbHourglass
Set DTB = CreateDatabase(DbLokasi & "\" & DbNama, dbLangGeneral)

Set Tabel = DTB.CreateTableDef("Login")
With Tabel
.Fields.Append .CreateField("UserName", dbText)
.Fields.Append .CreateField("Password", dbText)
End With
DTB.TableDefs.Append Tabel

Set Tabel = Nothing
DTB.Close
Screen.MousePointer = vbDefault

End Function

'Ketik Coding berikut pada Form

Private Sub Form_Load()
DbLokasi = App.Path
DbNama = "DBase.mdb"

If Dir(DbLokasi & "\" & DbNama) <> "" Then
Kill DbLokasi & "\" & DbNama
End If

Call CreateDB
End Sub
 
Persiapan yang di lakukan :
Buat Project baru stardart exe .. lalu ketik coding berikut pada form sobat


Private Sub Vibrate(frm As Form, rScale As Integer, Times As Integer)
Dim Lft As Long, Tp As Long
Dim i
Lft = frm.Left
Tp = frm.Top
For i = 1 To Times
frm.Move Lft + Sgn(rScale)
Pause 20
frm.Move Lft + rScale
Pause 20
frm.Move Lft, Tp + Sgn(rScale), frm.Width, frm.Height
Pause 20
frm.Move Lft, Tp + rScale, frm.Width, frm.Height
Pause 20
Next i
End Sub

Private Sub Pause(ms)
Dim secs
Dim g
secs = ms / 1000
g = Timer
Do While Timer - g < secs
DoEvents
Loop
End Sub

Private Sub Form_Activate()
Vibrate Me, 100, 20
 
 membuat ini file

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


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
 

Tidak ada komentar:

Posting Komentar