我需要帮助我的13行代码(运行时错误) [英] i need help with my 13 lines of code (run time error)

查看:95
本文介绍了我需要帮助我的13行代码(运行时错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我设法创建了一个简单的应用程序,当按下Esc键时杀死notepad.exe,无论我在哪个窗口

hello , i managed to make a simple app that kills notepad.exe when Esc Key Is pressed no matter in which window i am

这里是代码:

Public Class Form1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
    Private Const ESCAPE = &H1B
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim P As Process() = Process.GetProcessesByName("notepad")
        If (GetAsyncKeyState(ESCAPE)) Then
            P(0).Kill()
            MessageBox.Show("notepad has been terminated successfully", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

End Class

现在,当我运行代码时,我得到了这个错误,即使我编译它:

now when i run the code i get this error , even when i compile it :

https://i.imgur.com/YqP9JPK.png

https://i.imgur.com/YqP9JPK.png

我是新的,并且不知道发生了什么 

im new for all this and have no idea what's happening 

任何帮助都将受到赞赏< 3 

any help would be appreciated <3 

ps:我正在使用vb 2008 express 

ps: im using vb 2008 express 

推荐答案





这里是代码:

Public Class Form1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
    Private Const ESCAPE = &H1B
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim P As Process() = Process.GetProcessesByName("notepad")
        If (GetAsyncKeyState(ESCAPE)) Then
            P(0).Kill()



现在当我运行代码时我得到了这个错误,即使我编译它:

now when i run the code i get this error , even when i compile it :

https://i.imgur.com/YqP9JPK.png

https://i.imgur.com/YqP9JPK.png





这篇关于我需要帮助我的13行代码(运行时错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆