大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
可以试着用典型的VB字符串函数UCase解决。
网站建设、网站设计,成都做网站公司-创新互联已向上千家企业提供了,网站设计,网站制作,网络营销等服务!设计与技术结合,多年网站推广经验,合理的价格为您打造企业品质网站。
比如先把输入的内容放到字符串A$中,若A$="a",则经
A$=UCase(A$)转换后,结果即是A$="A"。
我在程序中是这麽处理的。行不行,试试就知道了。
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim s As String = "0Ff0ajkh04624F"
Dim i As Integer = 0
Dim sTemp As String = ""
Dim ss As String = ""
For i = 1 To Strings.Len(s)
sTemp = Mid(s, i, 1)
If Asc(sTemp) = 65 And Asc(sTemp) = 90 Then
sTemp = LCase(sTemp)
ElseIf Asc(sTemp) = 95 And Asc(sTemp) = 122 Then
sTemp = UCase(sTemp)
Else
sTemp = sTemp
End If
ss = ss sTemp
Next
MsgBox(ss)
End Sub
修改不大容易,干脆给你写一个吧。建一个Text1,Command1。
代码如下。
==================
Private Sub Command1_Click()
Const ascla = 97 'Asc("a")
Const asclz = 122 'Asc("z")
Const ascuA = 65 'Asc("A")
Const ascuZ = 90 'Asc("Z")
Dim i As Long, t As String, ascii As Integer
t = Text1.Text
If Asc(Left(t, 1)) = ascla And Asc(Left(t, 1)) = asclz Then t = UCase(Left(t, 1)) Mid(t, 2)
For i = 2 To Len(t)
ascii = Asc(Mid(t, i, 1))
If ascii = ascla And ascii = asclz Then
Dim ascl As Integer
ascl = Asc(Mid(t, i - 1, 1))
If ascl ascuA Or (ascl ascuZ And ascl ascla) Or ascl asclz Then
t = Left(t, i - 1) UCase(Mid(t, i, 1)) Mid(t, i + 1)
End If
End If
Next
Text1.Text = t
End Sub
1:将文件拷贝到WORD中
2:点击菜单“格式”——更改大小写,出现对话框
3:可以选择“大写”或者“切换大小写”,就都可以换过来了
最后,再复制回到你所需要的文档中即可!
Private Sub Command1_Click()
Dim a As String, b As String
a = Text1.Text
b = Right(a, Len(a) - 1)
a = UCase(Left(a, 1))
Text1.Text = a b
End Sub一个text控件。一个command控件。len函数(string)求字符串的字符长度。left(string,n)从string字符串左边开始取n个字符。right(string,n)从string字符串右边开始取n个字符。ucase(string) 将字符串string中所有小写字母改成大写。Private Sub Text1_LostFocus()
Dim a As String, b As String
a = Text1.Text
b = Right(a, Len(a) - 1)
a = UCase(Left(a, 1))
Text1.Text = a b
End Sub lostfocus 焦点离开事件。 在text中输入字母后。当鼠标点击别的按钮时,text控件失去焦点。触发事件。也可以按tab键使text失去焦点。