vb程序 大写字母转小写,小写转大写

1. 编写程序,完成以下操作:输入一个字符,如果它是大写英文字母,则将其转换为小写英文字母;如果它是小写英文字母,则将其转换为大写英文字母;如果是非英文字母,则不作处理。
2. 编写程序,要求输入一年份,判断出是否为闰年。闰年的条件是能被4整除,但不能被100整除;或者能被4整除又能被400整除(如:1992年,2000年均为闰年)。

用vb的选择性结构方面的知识做

'第一题
Private Sub Command1_Click()
a = InputBox("")
Select Case Asc(a)
Case Asc("a") To Asc("z")
Print UCase(a)
Case Asc("A") To Asc("Z")
Print LCase(a)
End Select
End Sub

'第二题
Private Sub Command1_Click()
a = Val(InputBox(""))
If (a Mod 4 = 0 And a Mod 100 <> 0) Or a Mod 400 = 0 Then
Print a & "是闰年"
Else
Print a & "不是闰年"
End If
End Sub
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-11-10
1.
Private Sub Command1_Click()
Dim strTmp As String, strC As String, strNew As String
Dim i As Integer
strTmp = "fsdfDSFAdfsaafds3424dfDDFEerwqdsfdsfD"
For i = 1 To Len(strTmp)
strC = Mid(strTmp, i, 1)
strNew = strNew & IIf(Asc(strC) >= 97 And Asc(strC) <= 122, UCase(strC), LCase(strC))
Next
Debug.Print strNew
End Sub

2.
Private Sub Form_Load()
Dim strInput As String
strInput = InputBox("请输入年份:")
If Trim(strInput) <> "" Then
strInput = Val(strInput)
Select Case True
Case (strInput Mod 4 = 0 And strInput Mod 100 <> 0) Or (strInput Mod 100 = 0 And strInput Mod 400 = 0)
Debug.Print strInput & "年是闰年"
End Select
'If (strInput Mod 4 = 0 And strInput Mod 100 <> 0) Or (strInput Mod 100 = 0 And strInput Mod 400 = 0) Then
'Debug.Print strInput & "年是闰年"
'End If
End If
End Sub
第2个回答  2009-11-10
1,Ucase函数和Lcase函数.大小写转换
2,if a/4=a\4 and a/100<>a\100 then
msgbox "闰年"
else
msgbox "非闰年"
end if

vb程序 大写字母转小写,小写转大写
'第一题 Private Sub Command1_Click()a = InputBox("")Select Case Asc(a)Case Asc("a") To Asc("z")Print UCase(a)Case Asc("A") To Asc("Z")Print LCase(a)End Select End Sub '第二题 Private Sub Command1_Click()a = Val(InputBox(""))If (a Mod 4 = 0 And a Mo...

vb程序编写 输入一个字符,如果是大写则转换为小写输出,如果是小写则...
在窗体中插入两个文本框,一个命令按钮。代码如下:Private Sub Command1_Click()If Asc(Text1.Text) >= 65 And Asc(Text1.Text) <= 90 Then Text2.Text = Chr(Asc(Text1.Text) + 32)Else If Asc(Text1.Text) >= 97 And Asc(Text1.Text) <= 122 Then Text2.Text = Chr(Asc(Te...

怎么实现在vb中,金额大小写转换啊?
Rmbda As String, Expda As String, Lent As Integer, Ntyp As Integer, Icnt As Integer, i As Integer, Trmb As StringRmb = Format(Rmb, "###0.00")If Rmb > 999999999999.99 ThenRMBChinese = "需转换的金额整数长度超过了12位!"...

在VB中,键盘输入一行字符,将其中的大写字母变为小写字母,小写字母变为...
Private Sub Command1_Click()Dim oldstr As String, newstr As String, temp As String * 1, i oldstr = InputBox("输入一行字符,回车结束!")For i = 1 To Len(oldstr)temp = Mid(oldstr, i, 1)If UCase(temp) <> temp Then temp = UCase(temp)Else temp = LCase(temp)End I...

在vb中输入一段英文有大写也有小写,然后将英文转换成全部大写或者小写...
全部转换成小写:Lcase(英文字符串)全部转换成大写:Ucase(英文字符串)

vb编写程序对输入字符串进行大小写转换。
可以参考下面的代码:Private Sub Command1_Click()Cls x = InputBox("")Picture1.Print UCase(x) '大写 Picture1.Print LCase(x) '小写 End Sub

...小写字母转换成大写字母,大写字母转换成小写字母,空格不转换,其余字 ...
- 32)If Asc(zf) = 32 Then Text2.Text = Text2.Text & " "If Asc(zf) >= 33 And Asc(zf) <= 64 Or Asc(zf) >= 91 And Asc(zf) <= 96 Or Asc(zf) >= 133 Then Text2.Text = Text2.Text + "+"Next End Sub 通过ascii判断字符是大写、小写还是其它。已经实验成功 ...

VB程序大写转小写
if asc(text1.text)>=65 and asc(text1.text)<=90 then '如果是大写 text2.text=Lcase(text1.text) '转小写 elseif asc(text1.text)>=97 and asc(text1.text)<=122 then '如果是小写 text2.text=Ucase(text1.text) '转大写 end if ...

vb 大小写转换函数 大写换小写。。小写换大写、。。急!!!
Dim X As String Dim I As Long Dim S As String Dim CH As String X = Text1.Text For I = 1 To Len(X)CH = Mid(X, I, 1)If CH >= "a " And CH <= "z" Then S = S + UCase(CH)ElseIf CH >= "A" And CH <= "Z" Then S = S + LCase(CH)End If Next I...

VB中的Sub定义,定义:大小写转换的代码
可以直接用函数啊 转大写 UCase 转小写 LCase

相似回答