Animasi Pada Visual Basic
Mengakses Kalkulator Windows
Jika Anda tidak bisa atau mungkin malas membuat kalkulator sendiri, gunakan saja kalkulator bawaan windows. Kodenya adalah :
Shell ("calc.exe")
Kode diatas hanya sekedar digunakan untuk menjalankan kalkulator, namun jika Anda menginginkan tidak terjadinya duplikasi atau penggandaan, ikuti langkah berikut :
1. Di bagian '(Declarations)' dari Form ketikkan :
[ VB 6.0 ]
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
[ VB .NET ]
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String)
As Integer
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer
2. Untuk menjalankannya ketikkan :
Dim l
l = FindWindow("scicalc", vbNullString)
If l = 0 Then
Shell ("calc.exe")
Else
SetForegroundWindow (l)
End If
l = FindWindow("scicalc", vbNullString)
If l = 0 Then
Shell ("calc.exe")
Else
SetForegroundWindow (l)
End If
Comments
Post a Comment
Tinggalkan Komentar