Kamis, 19 Januari 2012

Messagebox variasi di Visual Basic

Program vb saya kali ini membuat bahasa pemrograman sederhana dengan menggunakan istilah-istilah lain. tapi maksud dan tujuannya adalah sama saja. hanya agar lebih bervariasi dalam penggunaannya. berikut ini adalah contoh form depannya:


desain sesuai dengan form yang saya buat ya, biar proses belajar na mudah.
untuk awalnya commandbutton1 = "hello there"




Listing Codenya:

Private Sub Command1_Click()
    MsgBox "Hello there!"
End Sub
=====================================
untuk commandbutton2 = "last name1"

Private Sub Command2_Click()
    MsgBox "The Last Name field must not be blank.", _
           vbExclamation, _
           "Last Name"
End Sub
========================================
untuk commandbutton3 = "last name2"

listing Code:

Private Sub Command3_Click()
    MsgBox "The Last Name field must not be blank.", _
           vbExclamation + vbOKOnly, _
           "Last Name"
End Sub
===========================================
untuk commandbutton4 = "last name3"

Private Sub Command4_Click()
    MsgBox "The Last Name field must not be blank.", 48, "Last Name"
End Sub
==========================================
untuk commandbutton5 = "bad DB error"

lisitng code:

Private Sub Command5_Click()
    MsgBox "A bad database error has occurred.", _
           vbCritical, _
           "UpdateCustomerTable"
End Sub

============================================
untuk commandbutton6 = "Are you sure1"

lisitng code:

Private Sub Command6_Click()
   
    Dim intResponse As Integer
   
    intResponse = MsgBox("Are you sure you want to quit?", _
                         vbYesNo + vbQuestion, _
                         "Quit")
    If intResponse = vbYes Then
        'penggunaan if dengan hasil cetak dibawah ini pada form
        Print "App would have ended at this point"
    End If

End Sub
=============================================
untuk commandbutton7 = "Are you sure2"

listing code:

Private Sub Command7_Click()
   
    Dim intResponse As Integer
   
    intResponse = MsgBox("Are you sure you want to quit?", 36, "Quit")
    If intResponse = 6 Then
        'penggunaan if dengan hasil cetak dibawah ini pada form
        Print "App would have ended at this point"
    End If

End Sub

=============================================


untuk commandbutton8 = "Are you sure3"

listing code:

Private Sub Command8_Click()
   
    If MsgBox("Are you sure you want to quit?", _
          vbYesNo + vbQuestion, _
          "Quit") = vbYes Then
          'penggunaan if dengan hasil cetak dibawah ini pada form
          Print "App would have ended at this point"
    End If

End Sub

==============================================

untuk commandbutton9 = "Are you sure4"

listing code:

Private Sub Command9_Click()

    Dim intResponse As Integer

    intResponse = MsgBox("Are you sure you want to delete all of the rows " _
                       & "in the Customer table?", _
                         vbYesNo + vbQuestion + vbDefaultButton2, _
                         "Delete")
    If intResponse = vbYes Then
        ' ini mencetak delete rows ketika sukses delete table
        Print "Rows would have been deleted at this point"
    End If

End Sub

==========================================

untuk commandbutton10 = "exit"

listing code:

end

Sumber : Link

Tidak ada komentar:

Posting Komentar