| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 931 人关注过本帖
标题:这段代码的错误在哪?
只看楼主 加入收藏
gantanhao
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2008-2-4
收藏
 问题点数:0 回复次数:1 
这段代码的错误在哪?
在网上找到的一段代码。很想用用,可惜试了半天还是有3个错误,5个警告。希望大家帮帮忙。解决。小弟先谢谢大家。

代码如下:

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents lbxprocess As System.Windows.Forms.ListBox
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents txtsendtxt As System.Windows.Forms.TextBox
    Friend WithEvents txtsendtimes As System.Windows.Forms.TextBox
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txttimer As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
         = New ()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.lbxprocess = New System.Windows.Forms.ListBox()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.txtsendtxt = New System.Windows.Forms.TextBox()
        Me.txtsendtimes = New System.Windows.Forms.TextBox()
        Me.Timer1 = New System.Windows.Forms.Timer()
        Me.txttimer = New System.Windows.Forms.TextBox()
        Me.Button3 = New System.Windows.Forms.Button()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(144, 240)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(64, 24)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "发送"
        '
        'lbxprocess
        '
        Me.lbxprocess.ItemHeight = 12
        Me.lbxprocess.Location = New System.Drawing.Point(40, 16)
        Me.lbxprocess.Name = "lbxprocess"
        Me.lbxprocess.Size = New System.Drawing.Size(216, 88)
        Me.lbxprocess.TabIndex = 1
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(40, 240)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(64, 24)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "刷新进程"
        '
        'txtsendtxt
        '
        Me.txtsendtxt.Location = New System.Drawing.Point(40, 120)
        Me.txtsendtxt.Multiline = True
        Me.txtsendtxt.Name = "txtsendtxt"
        Me.txtsendtxt.Size = New System.Drawing.Size(216, 80)
        Me.txtsendtxt.TabIndex = 3
        Me.txtsendtxt.Text = ":D"
        '
        'txtsendtimes
        '
        Me.txtsendtimes.Location = New System.Drawing.Point(40, 208)
        Me.txtsendtimes.Name = "txtsendtimes"
        Me.txtsendtimes.Size = New System.Drawing.Size(40, 21)
        Me.txtsendtimes.TabIndex = 4
        Me.txtsendtimes.Text = "10"
        '
        'Timer1
        '
        '
        'txttimer
        '
        Me.txttimer.Location = New System.Drawing.Point(168, 208)
        Me.txttimer.Name = "txttimer"
        Me.txttimer.Size = New System.Drawing.Size(32, 21)
        Me.txttimer.TabIndex = 5
        Me.txttimer.Text = "5"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(216, 208)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(48, 24)
        Me.Button3.TabIndex = 6
        Me.Button3.Text = "设定"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(104, 216)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 16)
        Me.Label1.TabIndex = 7
        Me.Label1.Text = "发送间隔"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.Button3, Me.txttimer, Me.txtsendtimes, Me.txtsendtxt, Me.Button2, Me.lbxprocess, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'If lbxprocess.SelectedItem = "" Then
            ' MessageBox.Show(lbxprocess.Items(0))
            'End If

        If lbxprocess.Items.Count > 0 Then
            Try
                AppActivate(lbxprocess.Items(0))
                ' MessageBox.Show(txtsendtxt.Text)
                Dim i As Integer
                Dim c As Clipboard
                c.SetDataObject(txtsendtxt.Text)
                For i = 1 To CInt(txtsendtimes.Text)
                    Dim s As SendKeys
                    s.Send("^V")
                    s.Send("{Enter}")
                Next
            Finally
                'MessageBox.Show("Error!")
            End Try
        Else
            Call getProcessList()
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call Button2_Click(Me, e)
    End Sub

    Private Sub getProcessList()
        Dim p As Process()
        Dim inst As Process
        p = Process.GetProcessesByName("msnmsgr")
        lbxprocess.Items.Clear()
        For Each inst In p
            If inst.MainWindowTitle <> "MSN Messager" Then
                lbxprocess.Items.Add(inst.MainWindowTitle)
            End If
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim p As Process()
        Dim inst As Process
        p = Process.GetProcessesByName("msnmsgr")
        lbxprocess.Items.Clear()
        For Each inst In p
            If inst.MainWindowTitle <> "MSN Messager" Then
                lbxprocess.Items.Add(inst.MainWindowTitle)
            End If
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Timer1.Enabled = False Then
            txtsendtimes.Text = "1"
            Timer1.Interval = CType(txttimer.Text, Integer) * 1000
            Timer1.Enabled = True
            Button3.Text = "停止"
        Else
            Timer1.Enabled = False
            Button3.Text = "开始"
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Call Button1_Click(Me, e)
    End Sub
End Class
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 代码 New 窗体 Public Windows 
2008-04-19 11:46
gantanhao
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2008-2-4
收藏
得分:0 
帖子掉的好快,把它顶上去
2008-04-22 15:38
快速回复:这段代码的错误在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042018 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved