Di sini menerima pembuatan Program Aplikasi, bila anda berminat bisa kontak lewat via Email rizal.lonly@gmail.com, dan bila ada link yang rusak segera hubungi admin, Terima kasih atas kunjungannya.

Script Code : Buat Form Kartu Kredit

Posted on
  • Friday, December 9, 2011
  • by
  • Rizal
  • in
  • Labels:
  • Di sini saya akan memberikan script coding VB (Visual Basic). Anda pasti sudah tahu apa VB? kalau belum tahu VB (Visual Basic) adalah bahasa pemprograman yang menawarkan Integrated Development Environment (IDE) visual untuk membuat program perangkat lunak berbasis sistem operasi Microsoft Windows dengan menggunakan model pemprograman (COM), Visual Basic merupakan turunan bahasa pemprograman BASIC dan menawarkan pengembangan perangkat lunak komputer berbasis grafik dengan cepat. Panjang bener, intinya VB adalah bahasa pemprograman miliknya Microsoft, baiklah saya mulai :
    Keterangan Gambar.
    Script Code :
    Option Explicit
    'Dim vbIndex untuk tombol pilihan
    Dim vbIndex As Integer
    -----------------------------------------------------------------------------------------
    Private Sub cmdCheck_Click()
    Dim vbNumber As String
    Dim vbInstr As Integer
    Dim vbTemp As String
    Dim vbNumber2 As String
    'Jika kotak teks kosong dan akan keluar pesan
    If IsNull(txt_Number) Then
    MsgBox "Tolong di Masukkan Nomor.", vbExclamation + vbOKOnly, "Masukkan Nomor"
    Exit Sub
    Else 'Untuk memverifikasi variabel String
    vbNumber = txt_Number
    End If
    'Perintah untuk menyisipkan gambar
    Picture1.Visible = True
    'vbInstr akan memeriksa dalam String dan mengurai keluar
    vbInstr = 1
    'Menginisialisasi variabel String kosong
    vbTemp = ""
    While vbInstr > 0 'Untuk menguraikan String
    vbInstr = InStr(vbNumber, "-")
    If vbInstr > 0 Then
    'Akhir String
    vbNumber2 = Left$(vbNumber, vbInstr - 1)
    Else ' String vbNumber2 akan menguraikan variabel String
    vbNumber2 = vbNumber
    End If
    'Menetapkan String
    vbNumber = Right$(vbNumber, Len(vbNumber) - vbInstr)
    vbTemp = vbTemp + vbNumber2
    Wend
    'vbTemp untuk menetapkan panjang
    If Len(vbTemp) > 1 Then
    vbNumber = vbTemp
    End If
    'Memuat dan menampilkan gambar yang sesuai
    Select Case Left$(vbNumber, 1)
    Case "4" ' Visa
    Picture1.Picture = LoadPicture(App.Path + "\visa.gif")
    Case "5" 'Mastercard
    Picture1.Picture = LoadPicture(App.Path + "\mcard.gif")
    Case "6" 'Discover
    Picture1.Picture = LoadPicture(App.Path + "\discover.gif")
    Case "3" ' American Express
    Picture1.Picture = LoadPicture(App.Path + "\amex.gif")
    Case Else 'None
    Picture1.Visible = False
    End Select
    txt_Verify.SetFocus
    'Memverifikasi nomor
    If CheckCard(vbNumber) = False Then
    txt_Verify.Text = "Nomor salah."
    Else
    txt_Verify.Text = "Nomor benar."
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Function CheckCard(CCNumber As String) As Boolean
    Dim vbCounter As Integer
    Dim vbInt As Integer
    Dim vbAnswer As Integer
    vbCounter = 1
    vbInt = 0
    'Semua angka akan dihitung
    While vbCounter <= Len(CCNumber)
    'Melakukan cek LUHN
    vbInt = Val(Mid$(CCNumber, vbCounter, 1))
    'Memeriksa posisi yang ganjil
    If Not (vbCounter Mod 2) Then
    vbInt = vbInt * 2
    If vbInt > 9 Then vbInt = vbInt - 9
    End If
    vbAnswer = vbAnswer + vbInt
    vbCounter = vbCounter + 1
    Wend
    vbAnswer = vbAnswer Mod 10 'Dibagi 10
    If vbAnswer = 0 Then ' Kartu benar
    CheckCard = True
    Else
    CheckCard = False ' Kartu salah
    End If
    End Function
    -----------------------------------------------------------------------------------------
    Private Sub cmdGenerate_Click()
    Dim vbCounter As Integer
    Dim vbInt As Integer
    Dim vbAnswer As String
    Dim vbStart As String
    Dim vbFirst(11) As String
    Dim vbBool As Boolean
    Dim vbSet As Integer
    Dim vbLength As Integer
    vbBool = False
    While vbBool = False
    Randomize
    vbInt = 0
    Picture1.Visible = True
    Select Case vbIndex
    Case 1 'Konfigurasi Visa banks
    vbFirst(1) = "4032"
    vbFirst(2) = "4128"
    vbFirst(3) = "4250"
    vbFirst(4) = "4312"
    vbFirst(5) = "4421"
    vbFirst(6) = "4539"
    vbFirst(7) = "4556"
    vbFirst(8) = "4673"
    vbFirst(9) = "4722"
    vbFirst(10) = "4800"
    vbFirst(11) = "4833"
    vbSet = Int(11 * Rnd) + 1
    vbStart = vbFirst(vbSet)
    vbLength = 16
    Picture1.Picture = LoadPicture(App.Path + "\(punya-rizal.blogspot.com)visa.gif")
    Case 2 'Mastercard
    vbFirst(1) = "510813" ' Bank
    vbSet = 1
    vbStart = vbFirst(vbSet)
    vbLength = 16
    Picture1.Picture = LoadPicture(App.Path + "\(punya-rizal.blogspot.com)mcard.gif")
    Case 3 'American Express Banks
    vbFirst(1) = "372034"
    vbFirst(2) = "372407"
    vbFirst(3) = "372861"
    vbFirst(4) = "373227"
    vbSet = Int(4 * Rnd) + 1
    vbStart = vbFirst(vbSet)
    vbLength = 15
    Picture1.Picture = LoadPicture(App.Path + "\(punya-rizal.blogspot.com)amex.gif")
    Case 4 'Discover
    vbFirst(1) = "601100" 'Bank
    vbSet = 1
    vbStart = vbFirst(vbSet)
    vbLength = 16
    Picture1.Picture = LoadPicture(App.Path + "\(punya-rizal.blogspot.com)discover.gif")
    End Select
    While Len(vbStart) < vbLength
    vbInt = Int((9 * Rnd) + 1)
    If Not (vbCounter Mod 2) Then
    vbInt = vbInt * 2
    If vbInt > 9 Then
    vbInt = vbInt - 9
    End If
    ElseIf (vbCounter Mod 2) Then
    vbInt = vbInt * 2
    If vbInt > 9 Then
    vbInt = vbInt - 9
    End If
    End If
    vbStart = vbStart + LTrim$(Str$(vbInt))
    vbCounter = vbCounter + 1
    Wend
    If CheckCard(vbStart) = False Then
    vbInt = 0
    txt_Verify.SetFocus
    txt_Verify.Text = "Nomor salah."
    Else
    vbBool = True
    txt_Number.SetFocus
    txt_Number.Text = vbStart
    txt_Verify.SetFocus
    txt_Verify.Text = "Nomor benar."
    End If
    Wend
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Load()
    'Mengisialisasi Index
    vbIndex = 1
    End Sub
    -----------------------------------------------------------------------------------------
    'Menetapkan index untuk opsi pilihan visa, mastercard, american express atau discover
    Private Sub opt_Click(Index As Integer)
    vbIndex = Index
    End Sub
    Sekian dulu informasi dari saya, bila ada pertanyaan bisa lewat kotak komentar.
    Terima kasih, semoga bermanfaat!

    Baca Juga Artikel Terkait :

     
    Copyright © 2011 - 2012 Blogger templates by Rizal