码迷,mamicode.com
首页 > Web开发 > 详细

章鱼哥出品—VB.NET Office操作之Word(四)

时间:2014-11-02 09:23:55      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:office   vb.net   word   章鱼哥   

本文是在 章鱼哥出品—VB.NET Office操作之Word(二)中添加内容的具体实现,读者可以借鉴看下,注意本文应该与三结合在一起使用,是在三的基础上添加了几种功能的实现。

实现窗体:

 

bubuko.com,布布扣


代码实现:代码直接复制到上文的窗体类中

 

 

'*********************************************************************
'作者:章鱼哥,QQ:3107073263 群:309816713    
'如有疑问或好的建议请联系我,大家一起进步  
'*********************************************************************  
 '获取文档路径
    Private Sub But_GetAdrress_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_GetAdrress.Click
        Dim opendialog As New OpenFileDialog
        If opendialog.ShowDialog = DialogResult.OK Then
            TextBox1.Text = opendialog.FileName
        End If
    End Sub
    '获取当前鼠标的位置 
    Private Sub But_GetCursor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_GetCursor.Click
        For Each Word_Class As Class_Word1 In Array_Word
            Dim Cursor As ArrayList = Word_Class.GetCursor()
            If Cursor IsNot Nothing Then
                For i = 0 To Cursor.Count - 1
                    RichTextBox1.Text &= "  " & Cursor(i)
                Next
            End If
        Next
    End Sub

    '将光标移动到指定页
    Private Sub But_GoTo_Page_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_GoTo_Page.Click
        For Each Word_Class As Class_Word1 In Array_Word
            Word_Class.GoToPage(Tex_Page.Text)
        Next
    End Sub
    '光标移动到指定行(绝对)
    Private Sub But_GotoAbsoultRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_GotoAbsoultRow.Click
        For Each Word_Class As Class_Word1 In Array_Word
            Word_Class.GoToAbsolutLine(Tex_Row_Absoult.Text)
        Next
    End Sub
    '光标移动到指定行(相对)
    Private Sub But_GotoOppsitRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But_GotoOppsitRow.Click
        For Each Word_Class As Class_Word1 In Array_Word
            Word_Class.GoToOppsiteLine(Tex_Row_Oppsit.Text)
        Next
    End Sub

    '上下左右按钮,点击按钮一次移动一位
    Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
        'MsgBox("X:" & e.X & "Y:" & e.Y)
        Dim x As Integer = e.X
        Dim y As Integer = e.Y
        'RichTextBox1.Text &= "|" & e.X & ":" & e.Y
        For Each Word_Class As Class_Word1 In Array_Word
            If x > 70 And x < 130 Then
                If y > 20 And y < 45 Then
                    Word_Class.MoveUp()
                ElseIf y > 110 And y < 135 Then
                    Word_Class.MoveDown()
                End If

            End If
            If y > 45 And y < 105 Then
                If x > 40 And x < 65 Then
                    Word_Class.MoveLeft()
                ElseIf x > 135 And y < 160 Then
                    Word_Class.MoveRight()
                End If
            End If
        Next
    End Sub


 

章鱼哥出品—VB.NET Office操作之Word(四)

标签:office   vb.net   word   章鱼哥   

原文地址:http://blog.csdn.net/zhangyubishoulin/article/details/40685151

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!