Bahasa Pemrograman Visual

download Bahasa Pemrograman Visual

of 30

  • date post

    04-Jun-2018
  • Category

    Documents

  • view

    217
  • download

    0

Embed Size (px)

Transcript of Bahasa Pemrograman Visual

  • 8/13/2019 Bahasa Pemrograman Visual

    1/30

  • 8/13/2019 Bahasa Pemrograman Visual

    2/30

  • 8/13/2019 Bahasa Pemrograman Visual

    3/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 3

    STMIK HIMSYA SEMARANG

    Public rstptgs As ADODB.Recordset

    Public Sub BukaDB()Dim STR As String

    Set Conn = New ADODB.ConnectionSet rstmhs = New ADODB.RecordsetSet rstreg = New ADODB.RecordsetSet rstptgs = New ADODB.RecordsetConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbsiregina.mdb"End Sub

    7. Buat rancangan form-form seperti di bawah ini :

    Rancangan Form Menu

    Pengaturan Propertis MenuObyek Propertis Nilai

    Form NameCaptionWindowState

    menusireginaSTMIK HIMSYA SEMARANG2 Maximized

    Label1 NameCaption

    Alignment

    JudulSEMINAR NASIONAL TEKNOLOGI INFORMASI STMIK HIMSYA2 Center

    Timer1 NameInterval

    Timer1100

    Command1 NameCaption

    Command1Kosongkan

    Command2 NameCaption

    Command2STMIK

    Command3 NameCaption

    Command3Kosongkan

  • 8/13/2019 Bahasa Pemrograman Visual

    4/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 4

    STMIK HIMSYA SEMARANG

    Command4 NameCaption

    Command4HIMSYA

    Image1 NamePicture

    Image1Logo Stmik Himsya

    CrystalReport1 NameReportFileNameWindowState

    CR_MhsCari Lokasi File Report Mhs0 crptNormal

    CrystalReport2 NameReportFileNameWindowState

    CR_PtgsCari Lokasi File Report Ptgs0 crptNormal

    CrystalReport3 NameReportFileNameWindowState

    CR_RegCari Lokasi File Report Reg0 crptNormal

    Untuk membuat menu bar :Klik Tools Menu Editor

    Pengaturan Menu seperti berikut ini :Caption : FILEName : mnfileCaption : ExitName : mnexitCaption : DATAName : mndataCaption : Data MahasiswaName : mnmhsCaption : Data RegistrasiName : mnregCaption : REPORTName : mnreportCaption : Laporan Data Mahasiswa

  • 8/13/2019 Bahasa Pemrograman Visual

    5/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 5

    STMIK HIMSYA SEMARANG

    Name : mnlapmhsCaption : Laporan Data RegistrasiName : mnlapreg

    Kode Program MenuDim TEKS As StringDim PT, TK As Integer

    Private Sub mnExit_Click()EndEnd Sub

    Private Sub mnmhs_Click()frmmhs.Showmenusiregina.HideEnd Sub

    Private Sub mnreg_Click()frmRegistrasi.Showmenusiregina.HideEnd Sub

    Private Sub mnlapmhs_Click()CR_Mhs.ReportFileName = App.Path & "\LapDataMhs.rpt"CR_Mhs.WindowState = crptMaximizedCR_Mhs.RetrieveDataFilesCR_Mhs.Action = 1End Sub

    Private Sub mnlapreg_Click()

    CR_Reg.ReportFileName = App.Path & "\LapDataReg.rpt"CR_Reg.WindowState = crptMaximizedCR_Reg.RetrieveDataFilesCR_Reg.Action = 1End Sub

    Private Sub Form_Load()TEKS = Judul.CaptionPT = Len(TEKS)TK = 0End Sub

    Private Sub Timer1_Timer()

    TK = TK + 1If TK = PT + 10 ThenTK = 0

    End IfJudul = Left(TEKS, TK)

    End Sub

  • 8/13/2019 Bahasa Pemrograman Visual

    6/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 6

    STMIK HIMSYA SEMARANG

    Rancangan Form Login

    Pengaturan Propertis Form LoginObyek Propertis Nilai

    Form NameCaption

    FrmLoginLogin

    Label1 NameCaptionBorderStyle

    Label1Nama :1-Fixed Single

    Label2 NameCaption

    BorderStyle

    Label2Password :

    1-Fixed SingleLabel3 Name

    CaptionBorderStyle

    Label3Kode :1-Fixed Single

    Text1 NameText

    TxtNamaPtgsKosongkan

    Text2 NameText

    TxtPinPtgsKosongkan

    Text3 NameText

    TxtKodePtgsKosongkan

    Kode Program Form Login

    Dim A As ByteDim B As Byte

    Private Sub Form_Load()TxtNamaPtgs.MaxLength = 30TxtPinPtgs.MaxLength = 20TxtPinPtgs.PasswordChar = "*"TxtPinPtgs.Enabled = False

  • 8/13/2019 Bahasa Pemrograman Visual

    7/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 7

    STMIK HIMSYA SEMARANG

    TxtKodePtgs.Enabled = FalseEnd Sub

    Private Sub TxtNamaPtgs_KeyPress(Keyascii As Integer)

    Keyascii = Asc(UCase(Chr(Keyascii)))If Keyascii = 27 Then Unload MeIf Keyascii = 13 Then

    Call BukaDBrstptgs.Open "Select NamaPtgs from TPtgs where NamaPtgs =' " & TxtNamaPtgs & " ' ", Conn

    If rstptgs.EOF Then A = A + 1If 1 - A = 0 Then

    MsgBox "Kesempatan ke " & A & " Salah" & Chr(13) & _"Nama '" & TxtNamaPtgs & "' tidak dikenal"

    TxtNamaPtgs = ""TxtNamaPtgs.SetFocus

    ElseIf 2 - A = 0 ThenMsgBox "Kesempatan ke " & A & " Salah" & Chr(13) & _

    "Nama '" & TxtNamaPtgs & "' tidak dikenal"TxtNamaPtgs = ""TxtNamaPtgs.SetFocus

    ElseIf 3 - A = 0 ThenMsgBox "Kesempatan ke " & A & " Salah" & Chr(13) & _

    "Nama '" & TxtNamaPtgs & "' tidak dikenal" & Chr(13) & _"Kesempatan habis, Ulangi dari awal"

    Unload MeExit Sub

    End IfElse

    TxtNamaPtgs.Enabled = False

    TxtPinPtgs.Enabled = TrueTxtPinPtgs.SetFocus

    End IfEnd IfEnd Sub

    Private Sub txtpinptgs_KeyPress(Keyascii As Integer)Keyascii = Asc(UCase(Chr(Keyascii)))If Keyascii = 27 Then Unload MeDim LoginPtgs As StringDim KodePtgs As StringDim NamaPtgs As StringIf Keyascii = 13 Then

    Call BukaDBrstptgs.Open "Select * from TPtgs where NamaPtgs ='" & TxtNamaPtgs & "' and PinPtgs='" &

    TxtPinPtgs & "'", ConnIf rstptgs.EOF Then

    B = B + 1If 1 - B = 0 Then

    MsgBox "Kesempatan ke " & B & " Salah"

  • 8/13/2019 Bahasa Pemrograman Visual

    8/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 8

    STMIK HIMSYA SEMARANG

    TxtPinPtgs = ""TxtPinPtgs.SetFocus

    ElseIf 2 - B = 0 ThenMsgBox "Kesempatan ke " & B & " Salah"

    TxtPinPtgs = ""TxtPinPtgs.SetFocusElseIf 3 - B = 0 Then

    MsgBox "Kesempatan ke " & B & " Salah"'EndUnload MeExit Sub

    End IfElse

    FrmLogin.Visible = Falsemenusiregina.ShowKodePtgs = rstptgs!KodePtgsNamaPtgs = rstptgs!NamaPtgsKodePtgs = KodePtgsNamaPtgs = NamaPtgsfrmRegistrasi.KodePtgs = KodePtgsfrmRegistrasi.NamaPtgs = NamaPtgs

    End IfEnd IfEnd Sub

    Rancangan Form Mahasiswa

  • 8/13/2019 Bahasa Pemrograman Visual

    9/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 9

    STMIK HIMSYA SEMARANG

    Pengaturan Propertis Form Mahasiswa Obyek Propertis Nilai

    Form NameCaption

    FrmMhsStudent Data Entry

    Frame1 s/d Frame5 NameCaption Frame1 s/d Frame5KosongkanLabel1 Name

    Caption Alignment

    JudulStudent Data Entry2-Center

    Label2 NameCaption

    Label2NIM

    Label3 NameCaption

    Label3Nama Mahasiswa

    Label4 NameCaption

    Label3Program Studi

    Label5 NameCaption

    Alignment

    Label5Student Table

    2-CenterText1 NameText

    Text1Kosongkan

    Text2 NameText

    Text2Kosongkan

    Combo1 NameTextList

    Combo1KosongkanSistem Informasi - S1Teknik Informatika - S1

    Command1 NameCaption

    CmdInput&Input

    Command2 NameCaption

    CmdRefresh&Refresh

    Command3 NameCaption CmdHapus&HapusCommand4 Name

    CaptionCmdEdit&Edit

    Command5 NameCaption

    CmdTutup&Tutup

    Timer1 NameInterval

    Timer1100

    DataGrid1 NameDataSource

    DataGrid1 Adodc1

    Adodc1 NameCaptionVisible

    Adodc1MhsFalse

  • 8/13/2019 Bahasa Pemrograman Visual

    10/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 10

    STMIK HIMSYA SEMARANG

    Setting Adodc1 dengan cara klik kanan dan pilih ADODC Properties, seperti tampilan berikut;

    Kode Program Form Mahasiswa

    Dim TEKS As StringDim PT, TK As Integer

    Private Sub Form_Activate()Call BukaDB

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path &"\dbsiregina.mdb"

    Adodc1.RecordSource = "tmhs" Adodc1.RefreshSet DataGrid1.DataSource = Adodc1DataGrid1.RefreshEnd Sub

    Function CariData()Call BukaDBrstmhs.Open "Select * From tmhs where nim='" & text1 & "'", Conn

  • 8/13/2019 Bahasa Pemrograman Visual

    11/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 11

    STMIK HIMSYA SEMARANG

    End Function

    Private Sub KosongkanText()text1 = ""

    text2 = ""Combo1 = ""End Sub

    Private Sub SiapIsi()text1.Enabled = Truetext2.Enabled = TrueCombo1.Enabled = True

    End Sub

    Private Sub TidakSiapIsi()text1.Enabled = Falsetext2.Enabled = FalseCombo1.Enabled = False

    End Sub

    Private Sub KondisiAwal()KosongkanTextTidakSiapIsicmdINPUT.Caption = "&Input"cmdEdit.Caption = "&Edit"cmdHapus.Caption = "&Hapus"cmdTutup.Caption = "&Tutup"cmdINPUT.Enabled = TruecmdEdit.Enabled = TruecmdHapus.Enabled = True

    End Sub

    Private Sub TampilkanData()With rstmhs

    If Not rstmhs.EOF Thentext2 = rstmhs!namamhsCombo1 = rstmhs!prodi

    End IfEnd With

    End Sub

    Private Sub CmdRefresh_Click()If cmdINPUT.Caption = "&Simpan" Then

    cmdINPUT.SetFocus

    ElseIf cmdEdit.Caption = "&Simpan" ThencmdEdit.SetFocusEnd IfCall KondisiAwalForm_Activate

    End Sub

    Private Sub CmdInput_Click()

  • 8/13/2019 Bahasa Pemrograman Visual

    12/30

    MODUL Bahasa Pemrograman Visual 1

    Solikhin Halaman 12

    STMIK HIMSYA SEMARANG

    If cmdINPUT.Caption = "&Input" ThencmdINPUT.Caption = "&Simpan"cmdEdit.Enabled = FalsecmdHapus.Enabled = False

    cmdTutup.Caption = "&Batal"SiapIsiKosongkanTexttext1.SetFocus

    ElseIf text1 = "" Or text2 = "" Or Combo1 = "" Then

    MsgBox "Data Belum Lengkap...!"Else

    Dim SQLTambah As StringSQLTambah = "Insert Into tmhs (nim,Namamhs,prodi) values ('" & text1 & "','" & text2 & "','" &