Ini sebenarnya berguna untuk yang baru beralih dari vb 6 ke vb net, seperti penulis :D
Langsung saja yaak
mungkin pembaca pernah melihat source code seperti ini di VB6 :
Private Sub txtpassword_KeyPress(KeyAscii As Integer)Source code ini berfungsi pada textbox yang bernama txtpassword, jika menekan tombol Enter maka memanggil proses BTLogin_click.
If KeyAscii = 13 Then
BTlogin_Click
End If
End Sub
Sedangkan untuk di VB NET, source code diatas dirubah menjadi seperti berikut :
Private Sub Txtpassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpassword.keypress
If Asc(e.KeyChar) = 13 Then
BTLogin_Click(sender, New System.EventArgs())
end if
end sub
Bisa dilihat perbedaannya? :D
pada VB6 kita dapat menuliskan hanya "BTLogin_Click", sedangkan pada VB NET kita harus menuliskan "BTLogin_Click(sender, New System.EventArgs())" , Tanpa tanda kutip yaa :D
0 comments:
Post a Comment