Vb.net 在按下的键空间的文本框上附加符号
在按下的键空间的文本框上附加符号 你好,我想做一个搜索引擎程序,当他们按空格键时,我需要插入% 我成功地插入了符号Vb.net 在按下的键空间的文本框上附加符号,vb.net,Vb.net,在按下的键空间的文本框上附加符号 你好,我想做一个搜索引擎程序,当他们按空格键时,我需要插入% 我成功地插入了符号%,但它在后面放了一个空格。我想在没有空格的情况下附加符号 先谢谢你 这是我的密码 Public Class Form2 Public Sub New() Me.InitializeComponent() Me.KeyPreview = True End Sub Private Sub Button1_KeyDown(ByVal sender As Object,
%
,但它在后面放了一个空格。我想在没有空格的情况下附加符号
先谢谢你
这是我的密码
Public Class Form2
Public Sub New()
Me.InitializeComponent()
Me.KeyPreview = True
End Sub
Private Sub Button1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown
tbSearch.AppendText("%")
'If e.KeyCode = Keys.Space Then
'e.SuppressKeyPress = True
'End If
End Sub
Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Space Then
tbSearch.AppendText("%")
tbSearch.Text.Trim()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim pict = "https://i.ytimg.com/vi/" + TextBox1.Text + "/hqdefault.jpg?custom=true&w=168&h=94&stc=true&jpg444=true&jpgq=90&sp=68&sigh=6rUlsKOOsNW2_I8q7wgQJZ-z3Mw"
PictureBox1.ImageLocation = pict
Dim Link = "http://www.youtube.com/results?search_type=&search_query=" + TextBox1.Text + "&aq=f"
ProgressBar1.Value = 0
ProgressBar1.Value = 100
Form1.TextBox1.Text = Me.TextBox1.Text
MsgBox("Video Have Been Load And Are Ready To Play...")
ProgressBar1.Value = 0
Me.Close()
End Sub
Private Sub BackMainPageToolStripMenuItem_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
End Sub
Public Function SwapClipboardHtmlText( _
ByVal replacementHtmlText As String) As String
Dim returnHtmlText As String = Nothing
If (Clipboard.ContainsText(TextDataFormat.Html)) Then
returnHtmlText = Clipboard.GetText(TextDataFormat.Html)
Clipboard.SetText(replacementHtmlText, TextDataFormat.Html)
End If
Return returnHtmlText
TextBox1.Text = returnHtmlText
End Function
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
Dim pict = "https://i.ytimg.com/vi/" + TextBox1.Text + "/hqdefault.jpg?custom=true&w=168&h=94&stc=true&jpg444=true&jpgq=90&sp=68&sigh=6rUlsKOOsNW2_I8q7wgQJZ-z3Mw"
Me.WebBrowser2.ScriptErrorsSuppressed() = True
Me.WebBrowser1.ScriptErrorsSuppressed() = True
Dim info = "http://gdata.youtube.com/feeds/api/videos/" + tbSearch.Text
Me.WebBrowser2.Navigate("https://www.google.pt/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=" + tbSearch.Text + "&*")
Process.Start("chrome", "https://www.youtube.com/results?search_query=" + tbSearch.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Process.Start("chrome", "http://www.google.com/search?hl=en&q=" + tbSearch.Text + "&aq=f&oq=")
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tbSearch.Select()
MsgBox("Type Your Search Keyword And Press Search Youtube")
End Sub
End Class
您可以将设置为True
以使其忽略当前按下的键,但要使其正常工作,您必须处理文本框的
事件,而不是表单的事件
Private Sub tbSearch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbSearch.KeyDown
If e.KeyCode = Keys.Space Then
tbSearch.AppendText("%")
e.SuppressKeyPress = True
End If
End Sub
快速修复(粗略一看):tbSearch.Text.Trim()应该是:tbSearch.Text=tbSearch.Text.Trim(),如果我的答案解决了您的问题,请按我文章左侧的勾号/复选标记将其标记为已接受。有关更多信息,请参阅: