📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(560, 21)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "Please input a string ..."
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(248, 16)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Better Auto-Propercase:"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 397)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Prevent Multiple Instances of a .NET Windows Application"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
''Send opening form's TEXT property as a parameter to the function "ActivatePrevInstance"
''This works well with an MDI form or a non-MDI form
''It is advised that you give a Unique name to your Form so that it doe not conflict with other applications
'ActivatePrevInstance(Me.Text)
ActivatePrevInstance("Prevent Multiple Instances of a .NET Windows Application")
End If
End Sub
''''''''''''''''''''''''''''''''
'Better Auto-Propercase
'''''''''''''''''''''''''''''''
'VB 6.0 codes:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The "Auto-Propercase Text Box at Entry" tip [VBPJ May 1997, page 63] has a simpler solution. The StrConv
'function can propercase any string. You can achieve the same effect with this code in the KeyUp event of
' a text box:
' Private Sub Text1_KeyUp(ByVal KeyCode As Integer, _
' ByVal Shift As Integer)
' Dim iCurPos As Integer
' iCurPos = Text1.SelStart
' Text1.Text = StrConv(Text1, vbProperCase)
' Text1.SelStart = iCurPos
' End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Dim iCurPos As Integer
iCurPos = Me.TextBox1.SelectionStart
Me.TextBox1.Text = StrConv(Me.TextBox1.Text, VbStrConv.ProperCase)
Me.TextBox1.SelectionStart = iCurPos
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -