You are on page 1of 4

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

===============================================
3 Kali Validasi Login
==================================================================
===============================================

Public Class Form1


Dim kesempatan As Byte 'tambah ini
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Password.PasswordChar = "*"
kesempatan = 0 'tambah ini
End Sub
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnOk.Click
If Username.Text = "Aku" And Password.Text = "Sayang" Then
MsgBox("Selamat Datang", MsgBoxStyle.Information, "Login Success")
Me.Hide()
'FormMenu.Show()
ElseIf Username.Text = "Dia" And Password.Text = "Oke" Then
MsgBox("Selamat Datang", MsgBoxStyle.Information, "Login Success")
Me.Hide()
'FormMenu.Show()
Else
MsgBox("Maaf !, Password anda salah !", MsgBoxStyle.Information, "Login Gagal")
Username.Text = ""
Password.Text = ""
Username.Focus()
kesempatan = kesempatan + 1 'tambah ini
If kesempatan >= 3 Then
MsgBox("Maaf !, Anda sudah " & kesempatan & " kali salah !",
MsgBoxStyle.Information, "Login Gagal") 'tambah ini
End 'tambah ini
End If 'tambah ini
End If
End Sub
End Class

==================================================================
===============================================
Buka File Gambar
==================================================================
===============================================

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim lokasiGambar As String
Try
OpenFD.Filter = "Image Files(*.jpg,*.JPEG,*.bmp,*.gif,*.png) |
*.jpg;*.JPEG;*.bmp;*.gif;*.png"
OpenFD.ShowDialog()
lokasiGambar = OpenFD.FileName
If lokasiGambar <> "" Then
PictureBox1.Image = Image.FromFile(lokasiGambar)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class

==================================================================
===========
Disabled Tombol X pada Form
==================================================================
===========

If Not e.CloseReason = CloseReason.WindowsShutDown Then ' Membuat tombol X di


Form tidak bisa diclose
e.Cancel = True
End If

==================================================================
==========
DataGridView select 1 baris
==================================================================
==========
Private Sub dataGridView1_CellEnter(ByVal sender As Object, ByVal e As
DataGridViewCellEventArgs) Handles dataGridView1.CellEnter

dataGridView1.Rows(e.RowIndex).Selected = True
End Sub

==================================================================
==========
DataGridView ubah warna kalau Quantity kurang dari 5
==================================================================
==========
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As
DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells("Quantity:") < 5 Then
Me.DataGridView1.Rows(i).Cells("Quantity:").Style.ForeColor = Color.Red
End If
Next
End Sub

==================================================================
==========
Button Image Animation
==================================================================
==========
Private Sub simulateButtonPress(ByRef pictureBox As
Infragistics.Win.UltraWinEditors.UltraPictureBox)
pictureBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Inset
Application.DoEvents()
System.Threading.Thread.Sleep(400)
pictureBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Raised
Application.DoEvents()
End Sub
==================================================================
==========
Open Form in Other Monitor
==================================================================
==========
form2.Location=Screen.AllScreens(UBound(Screen.AllScreens)).Bounds.Location + new
Point(100,100)
==================================================================
==========
Warna DataGrid
==================================================================
==========
For i As Integer = 0 To Me.DataGridView1.Rows.Count 1
If Me.DataGridView1.Rows(i).Cells(stok).Value = 0 Then
Me.DataGridView1.Rows(i).Cells(stok).Style.BackColor = Color.Red
End If
Next

==================================================================
==========
TABPages
==================================================================
==========
If TabControl1.TabPages.Contains(tabDataPegawai) Then
TabControl1.SelectedTab = tabDataPegawai
Else
TabControl1.TabPages.Insert(0, tabDataPegawai)
TabControl1.SelectedTab = tabDataPegawai
End If

TabControl1.TabPages.Remove(tabDataPegawai)
==================================================================
==========
Lokasi Komponen Better Code
==================================================================
==========
label1.Top = 20
label1.left = 40
==================================================================
==========
DATETIMEPICKER AUTO MOVE TO OTHER
==================================================================
==========
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles DateTimePicker1.ValueChanged
SendKeys.Send("{/}")
End Sub
==================================================================

You might also like