vb.net选择文本,vb选择文件

VB.NET中怎样用API获得文本框中的选中文本

Public Declare Auto Function GetWindowText Lib "user32" Alias "GetWindowText" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer

创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于成都网站设计、网站建设、周口网络推广、小程序开发、周口网络营销、周口企业策划、周口品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供周口建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com

Public Declare Auto Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLength" (ByVal hwnd As Integer) As Integer

Public Function GetText(ByVal hwnd As Integer) As String

Dim nLen As Integer

nLen = GetWindowTextLength(hwnd)

GetText = Space(nLen)

GetWindowText(hwnd, GetText, nLen)

End Function

VS2008测试通过, 函数GetText传入的就是对应文本框的句柄.

vb.net怎么实现读取指定WORD文档中的内容

添加spire.doc.dll为引用,在vb.net中读取指定word文档的内容到 txt文件,代码示例如下:

'加载Word文档

Dim doc As Document = New Documentdocument.LoadFromFile("测试文档.docx")

'使用GetText方法获取文档中的所有文本

Dim s As String = doc.GetText

File.WriteAllText("文本1.txt", s.ToString)

vb.net textbox1选中的文本,拖放到textbox2?

很久没有上这里了,今天看到了这个问题,尝试做了一个;

本例以源文本框TextBox1全部文字作为拖放文字为例,实现拖放

1、向一个窗体中添加两个文本框,分别名为TextBox1,TextBox2。注意:把TextBox2控件的AllowDrop属性设置成True,这点不要遗漏。

2、完整的代码如下:

Public Class Form1

Private MouseIsDown As Boolean = False

Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown

'设置一个标志以显示鼠标已按下。

MouseIsDown = True

End Sub

Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove

If MouseIsDown Then

'开始拖动(将TextBox1的文本内容作为拖放内容)。

TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy)

End If

MouseIsDown = False

End Sub

Private Sub TextBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter

'检查正在被拖放的数据的格式。

If (e.Data.GetDataPresent(DataFormats.Text)) Then

'显示复制光标(表示是拖放行为)。

e.Effect = DragDropEffects.Copy

Else

'显示不放置光标(表示不是拖放行为)。

e.Effect = DragDropEffects.None

End If

End Sub

Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop

'粘贴文本(将拖放内容作为TextBox2的文本内容)。

TextBox2.Text = e.Data.GetData(DataFormats.Text)

End Sub

End Class


本文标题:vb.net选择文本,vb选择文件
URL网址:http://pwwzsj.com/article/hoihjd.html