Persiapan yang dilakukan:
- Buat Project Baru Standart exe
- Tambahkan 1 buah TextBox (Text1)
- Tambahkan 1 buah Label (Label1)
- Tambahkan 1 Buah CommandButton (Command1) caption : =
'Ketik Coding dibawah ini pada Form Project
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crColor As Long, ByVal nAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
Dim excel_app As Object
Dim excel_sheet As Object
Set excel_app = CreateObject("Excel.Application")
excel_app.Workbooks.Add
If Val(excel_app.Application.Version) >= 8 Then
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If
excel_sheet.Cells(1, 1) = "=" & Text1.Text
Label1.Caption = excel_sheet.Cells(1, 1)
Label1.Caption = Format$(Label1.Caption, "#,##0")
excel_app.ActiveWorkbook.Close False
excel_app.Quit
Set excel_sheet = Nothing
Set excel_app = Nothing
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1_Click
End Sub
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crColor As Long, ByVal nAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
Dim excel_app As Object
Dim excel_sheet As Object
Set excel_app = CreateObject("Excel.Application")
excel_app.Workbooks.Add
If Val(excel_app.Application.Version) >= 8 Then
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If
excel_sheet.Cells(1, 1) = "=" & Text1.Text
Label1.Caption = excel_sheet.Cells(1, 1)
Label1.Caption = Format$(Label1.Caption, "#,##0")
excel_app.ActiveWorkbook.Close False
excel_app.Quit
Set excel_sheet = Nothing
Set excel_app = Nothing
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1_Click
End Sub
Setelah semua selesai coba sobat ketik 20*10+(30-19) atau perkalian yang lain pada Text1 .. kemudian tekan enter atau click CommandButton .. pada Label1 akan didapat hasil perkalian tersebut.
Mudah-mudah ada mamfaatnya bagi kita semua khusus nya bagi rekan-rekan VB Developper yang masih junior seperti saya semoga Artikel ini bisa menambah perbendaharaan ilmu nya dan terima kasih sebelum bagi sobat-sobat yang sudah berkenan memberikan Argumen nya ... salam.
0 komentar:
Posting Komentar