vb点虐 填充字符 vba填充

VB.NET 向指定(网页或软件)的输入框内输入字符,如何实现?

假如Form1有个TextBox1,双击TextBox1填入123

曲松网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、自适应网站建设等网站项目制作,到程序开发,运营维护。成都创新互联于2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联

Public Class Form1

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Integer

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

End Sub

Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick

System.Windows.Forms.SendKeys.Send("123")

End Sub

End Class

看你的VB.NET 版本了

用 My.Computer.Keyboard.SendKeys("123", True) 代替 System.Windows.Forms.SendKeys.Send("123") 也可以

原码:

Public Class Form1

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

End Sub

Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick

My.Computer.Keyboard.SendKeys("123", True)

End Sub

End Class

Vb点虐 添加字符

有甚多办法,我说个最简单的

dim xstr as string = "abcde"

Xstr = "(" xstr ")"

vb点虐 实现ComboBox输入字符自动补充字符

Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs)

If cmb.DataSource Is Nothing Then

Return

End If

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then

Return

End If

Dim strFindStr As String = ""

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Back) Then

If (cmb.SelectionStart = cmb.Text.Length) Then

If cmb.Text.Length  0 Then

strFindStr = cmb.Text.Substring(0, cmb.Text.Length - 1)

End If

Else

If cmb.SelectionStart  0 Then

strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1)

End If

End If

e.Handled = False

Else

If (cmb.SelectionLength = 0) Then

strFindStr = cmb.Text + e.KeyChar

Else

If (cmb.SelectionStart = cmb.Text.Length) Then

strFindStr = e.KeyChar

Else

If cmb.SelectionStart  0 Then

strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1) + e.KeyChar

Else

strFindStr = e.KeyChar

End If

End If

End If

End If

Dim intIdx As Integer = -1

Dim dv As DataView

If TypeOf (cmb.DataSource) Is DataTable Then

dv = CType(cmb.DataSource, DataTable).DefaultView

If strFindStr  "" Then

dv.RowFilter = cmb.DisplayMember  " Like '%"  strFindStr  "%'"

Else

dv.RowFilter = ""

End If

cmb.DataSource = dv

cmb.SelectedIndex = -1

cmb.Text = strFindStr

Else

dv = CType(cmb.DataSource, DataView)

If strFindStr  "" Then

dv.RowFilter = cmb.DisplayMember  " Like '%"  strFindStr  "%'"

Else

dv.RowFilter = ""

End If

cmb.DataSource = dv

cmb.SelectedIndex = -1

cmb.Text = strFindStr

End If

cmb.SelectionStart = strFindStr.Length

e.Handled = True

End Sub

Private Sub comboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comboBox1.KeyPress

AutoComplete(sender, e)

End Sub


网站标题:vb点虐 填充字符 vba填充
当前链接:http://ybzwz.com/article/ddsdcgo.html