本文介绍了在已按下键空间的文本框上添加符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在已按下键空间的文本框上添加符号

Append a Symbol on textbox on key space pressed

您好,我尝试制作一个搜索引擎程序,我需要按空格键插入%wen.

Hi Hello, I Try To Make A Search Engine Program and i need to insert % wen they press space keyboard.

我已成功插入符号%,但在其后留有空白.

I Have Succeed To Insert The Symbol % but It Make The Empty space To After It.

我喜欢在没有空格的情况下附加符号.

I Liked To append The Symbol With Out The Empty Space.

提前与您联系

这是我的代码

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

推荐答案


这篇关于在已按下键空间的文本框上添加符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 13:50