VB.NET相關代碼整理

窗口雙緩衝

    Public Sub New()

        ' 此調用是 Windows 窗體設計器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 調用之後添加任何初始化。
        SetStyle(Windows.Forms.ControlStyles.OptimizedDoubleBuffer Or Windows.Forms.ControlStyles.ResizeRedraw Or Windows.Forms.ControlStyles.AllPaintingInWmPaint, True)

    End Sub

TextBox去除默認右鍵信息 

Public Class ClaTextbox

    Inherits System.Windows.Forms.TextBox

    Public Sub New()
        MyBase.New()
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg <> &H7B Then
            MyBase.WndProc(m)
        End If
    End Sub

End Class

正則表達式

'正則表達式
    Public Function GetRegex(ByVal txtStr As String, ByVal regStr As String, ByVal groupIndex As Integer) As String
        GetRegex = ""
        Dim reg As New System.Text.RegularExpressions.Regex(regStr)
        Dim matchs As System.Text.RegularExpressions.Match = reg.Match(txtStr)
        GetRegex = matchs.Groups(groupIndex).Value
    End Function

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章