不能使用ucase和lcase函数,你可以将字母字符转化成为数值,小写字母的值域是97-122,大写字母是65-90,用chr()和asc()这两个函数也可以实现大小写的转化的。
private
sub
form_click()
x
=
text1text
n
=
len(trim(x))
for
i
=
1
to
n
l
=
mid(x,
i,
1)
if
l
>
"h"
then
l
=
chr(asc(l)
-
32)
text2text
=
text2text
&
l
end
if
next
i
end
sub
Private Sub Form_Load()
Command1Enabled = False '使Command1不可用
Label2Visible = False '使Label2、、Label7不可见
Label3Visible = False
Label4Visible = False: Label5Visible = False
Label6Visible = False: Label7Visible = False
Label8Visible = False: Label9Visible = False
'Text1TabIndex = 0 '使文本框获得输入焦点
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1Enabled = True '输入结束,使Command1可用
End Sub
Private Sub Command1_Click() '单击Command1完成统计
Dim s As String, length As Integer, s1 As String
Dim n1 As Integer, n2 As Integer, n3 As Integer, wt As Boolean, n4 As Integer
s = Text1Text
length = Len(s)
n1 = 0: n2 = 0: n3 = 0
For i% = 1 To length
s1 = Mid(s, i%, 1)
If s1 >= "a" And s1 <= "z" Or s1 >= "A" And s1 <= "Z" Then
n1 = n1 + 1 '字母字符
ElseIf s1 >= "0" And s1 <= "9" Then
n2 = n2 + 1 '数字字符
Else
n3 = n3 + 1 '其它字符
End If
Next i%
Label5Caption = n1: Label6Caption = n2
Label7Caption = n3: Label2Visible = True '显示标签
Label3Visible = True: Label4Visible = True
Label5Visible = True: Label6Visible = True
Label7Visible = True
For i% = 1 To length '这个循环找到第一个单词的字母
s1 = Mid(s, i%, 1)
If s1 >= "a" And s1 <= "z" Or s1 >= "A" And s1 <= "Z" Then Exit For
Next i%
wt = False
For j% = i To length '从第一个单词的字母开始统计
s1 = Mid(s, j%, 1)
If s1 >= "a" And s1 <= "z" Or s1 >= "A" And s1 <= "Z" Then
If wt = False Then
n4 = n4 + 1
wt = True
End If
Else
wt = False
End If
Next j%
Label8Visible = True: Label9Visible = True
Label9Caption = n4
End Sub
Private Sub Command1_Click()
Const N = 10
Dim a(N) As String
For i = 1 To 10
Do
flag = True
a(i) = Chr(Asc("a") + Int(Rnd 26))
For j = 1 To i - 1
If a(i) = a(j) Then flag = False: Exit For
Next j
Loop Until flag
Next i
Print "随机不重复的字串是"
For i = 1 To N
Print a(i);
Next i
Max = a(1): Min = a(1)
For i = 1 To N
If Max < a(i) Then Max = a(i)
If Min > a(i) Then Min = a(i)
Next i
Print "最大的字符是:" & Max
Print "最小的字符是:" & Min
End Sub
Private Sub Command1_Click()
Dim a() As String, y As String, s As String
s = Text1Text
m = Len(Text1Text)
y = ""
ReDim a(m)
For i = 1 To m
a(i) = Mid(s, i, 1)
Next i
For i = 1 To m - 1
For j = i + 1 To m
If a(i) > a(j) Then
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i
For i = 1 To m
y = y + a(i)
Next i
Text2Text = y
End Sub
如果满意的话,就给加几分吧。。。。。。。。。谢谢啦
可用希腊字母的英文注音,如:
用sigma这个变量代替σ,
用alpha这个变量代替α,
用beta这个变量代替β,
用omega这个变量代替Ω,
附:希腊字母 中英文读音及常用意义对照一览表
序号 大写 小写 英文注音 国际音标注音 对应英文字母 中文读音 意 义 对应数值
1 Α α alpha a:lfa a 阿尔法 角度(小写);系数 1
2 Β β beta beta b, v 贝塔 磁通系数;磁感应强度(大写);角度(小写);系数 2
3 Γ γ gamma ga:m g, gh, y 伽马 电导系数(小写) 3
4 Δ δ delta delta d, dh, th 戴尔塔 变化量(大写);屈光度 4
5 Ε ε epsilon ep`silon e 艾普西龙 对数之基数;电势能(小写) 5
6 Ζ ζ zeta zeta z 截塔 系数;方位角;阻抗;相对粘度;原子序数 7
7 Η η eta eta e, i 艾塔 磁滞系数;效率(小写) 8
8 Θ θ theta θita th 西塔 温度;相位角 9
9 Ι ι iot jot i 约塔 微小,一点儿 10
10 Κ κ kappa kap k 卡帕 介质常数 20
11 ∧ λ lambda lamda l 兰姆达 波长(小写);体积 30
12 Μ μ mu mju m 缪 磁导系数微(千分之一)放大因数(小写);动摩擦因数(小写) 40
13 Ν ν nu nju n 纽 磁阻系数;光频率(小写),中微子(小写) 50
14 Ξ ξ xi ksi x, ks 克西 随机变量 60
15 Ο ο omicron omik`ron o 奥密克戎 无穷小量:ο(x) 70
16 ∏ π pi pai p 派 圆周率=圆周÷直径=314159 2653589793 80
17 Ρ ρ rho rou r 柔 电阻系数(小写)密度(小写) 100
18 ∑ σ sigma `sigma s 西格马 总和(大写),表面密度;跨导(小写) 200
19 Τ τ tau to: t 套 时间常数;周期(大写) 300
20 Υ υ upsilon jup`silon u, y, v, f 宇普西龙 位移 400
21 Φ φ phi fai ph, f 法爱 磁通(大写);电势(小写);黄金分割符号;工程学中表示直径(大写斜体) 500
22 Χ χ chi khi ch, kh 奇 卡方分布;电感 600
23 Ψ ψ psi psai ps 帕赛 角速;介质电通量(静电力线);角 700
24 Ω ω omega o`miga o 欧米伽 欧姆(大写);角速度(小写);角 800
Private Sub Form_Click()
Dim a$, s() As Byte, i%, st$
a = InputBox("字符串", , "sfsjlh8900-='[jFDHRe223oi")
s = StrConv(a, vbFromUnicode)
For i = UBound(s) To 0 Step -1
If (s(i) > 64 And s(i) < 91) Or (s(i) > 96 And s(i) < 123) Then st = st & Chr(s(i))
Next
Print a
Print st
End Sub
dim a as string
a=inputbox("请输入一个字符")
select case a
case "0" to "9"
msgbox "是数字"
case "a" to "z","A" to "Z"
msgbox "是字母"
case else
msgbox "是其它字符"
end select
以上就是关于英文字母大小写切换 怎样用VB 编程全部的内容,包括:英文字母大小写切换 怎样用VB 编程、vb程序,怎样统计文本框中大写英文字母、小写英文字母及数字的个数,希望有注释、vb程序设计随机产生10个不重复的a到z的大写字母,要求将10个字符,最大和最小字等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)