Private Sub Command1_Click()
繁昌ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
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失去焦点。
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
将第一个字母用 UCase 函数转换,然后再看句间的分隔符是什么,定位后,将分隔符后的第一个字母用UCase 函数转换就行了.
修改不大容易,干脆给你写一个吧。建一个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:可以选择“大写”或者“切换大小写”,就都可以换过来了
最后,再复制回到你所需要的文档中即可!
可以试着用典型的VB字符串函数UCase解决。
比如先把输入的内容放到字符串A$中,若A$="a",则经
A$=UCase(A$)转换后,结果即是A$="A"。
我在程序中是这麽处理的。行不行,试试就知道了。