VB2010实例(1)_字符大小写转换
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label3.Text = "e.KeyChar:"
Label4.Text = "e.KeyChar的值:"
End Sub
'清除文体框
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
'退出
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Label3.Text = Mid(Label3.Text, 1, 10) & e.KeyChar
Label4.Text = Mid(Label4.Text, 1, 10) & Convert.ToInt32(e.KeyChar)
Dim str As String
str = e.KeyChar
Select Case str
Case "a" To "z"
str = Chr(Convert.ToInt32(e.KeyChar) - 32)
Case "A" To "Z"
str = Chr(Convert.ToInt32(e.KeyChar) + 32)
Case Else
str = "*"
End Select
TextBox2.Text = TextBox2.Text & str
End Sub
End Class