假设两个textbox,textbox1放转换前的string,textbox2放转换后的string
按button1后执行
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strBefore, strAfter, strCurr As String
'strBefore:转换前的string
'strAfter 转换后的string
'strCurr 当前处理的string
strBefore = Me.TextBox1.Text.Trim
For i As Integer = 0 To strBefore.Length - 1
strCurr = strBefore.Substring(i, 1) '取第i位字符
If strCurr >= "a" And strCurr <= "z" Then '小写字符,转为大写
strCurr = strCurr.ToUpper
Else
If strCurr >= "A" And strCurr <= "Z" Then '大写字符,转为小写
strCurr = strCurr.ToLower
End If
End If
strAfter = strAfter & strCurr
Next
Me.TextBox2.Text = strAfter
End Sub
Imports Microsoft.VisualBasic
-----------------
Dim MyWord
MyWord = UCase("Hello World")
Dim MyString
Dim LCaseString
MyString = "VBSCript"
LCaseString = LCase(MyString)