Senin, 10 April 2017

Contoh Penggunaan Case & Timer Visual Studio 2015


KODINGNYA :

Public Class Form1
    Dim second As Integer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Label1.Text = "Serial Number Software"
        Me.Label2.Text = "Semakan Serial Number"
        Me.Label3.Text = "Serial Number"
        Me.Button1.Text = "Mulai"
        Me.Button2.Text = "Hasil"
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Timer1.Start()
        Call soal()
    End Sub
    Sub soal()
        If second = 0 Then
            Dim pertanyaan As Integer
            pertanyaan = Int(Rnd() * 3)
            Select Case pertanyaan
                Case 0
                    Me.TextBox1.Text = "12312-34-4555-Aj889"
                Case 1
                    Me.TextBox1.Text = "555-ZAweR-9999-CXX-hhul"
                Case 2
                    Me.TextBox1.Text = "ssss-cccc-zzzz-loPPN"
                Case 3
                    Me.TextBox1.Text = "ooooo-oooo-4555-RtyuxD"
            End Select
        End If
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        second = second + 1
        Me.Label4.Text = second
        If second = 120 Then
            second = 0
            Me.Timer1.Stop()
            MsgBox("maaf waktu anda habis maka serial number akan otomatis berubah")
            Me.TextBox1.Text = ""
            Me.TextBox2.Text = ""
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Timer1.Stop()
        If Me.TextBox1.Text = Me.TextBox2.Text Then
            MsgBox("serial sama, anda dapat mencrack softwarenya")
        Else
            MsgBox("serial salah, maka otomatis aplikasi keluar")
            Me.Close()
        End If
    End Sub
End Class


0 komentar:

Posting Komentar