VB程序编写代码问题?
wz=txtwz.Textle=Len(wz)Fori=1Tolewz=Mid(wz,1,le)IfAsc(wz)>=65AndAsc(wz)<=90Thenwz=LCa...
wz = txtwz.Text
le = Len(wz)
For i = 1 To le
wz = Mid(wz, 1, le)
If Asc(wz) >= 65 And Asc(wz) <= 90 Then
wz = LCase(wz)
Else
wz = UCase(wz)
End If
Next i
txtjg.Text = wz
请问这一段代码有什么问题,它只执行IF这个句就会跨过ELSE?
这段代码功能是将一个英文字符中的小写变大写,大写变小写.全由文本框输出输入. 展开
le = Len(wz)
For i = 1 To le
wz = Mid(wz, 1, le)
If Asc(wz) >= 65 And Asc(wz) <= 90 Then
wz = LCase(wz)
Else
wz = UCase(wz)
End If
Next i
txtjg.Text = wz
请问这一段代码有什么问题,它只执行IF这个句就会跨过ELSE?
这段代码功能是将一个英文字符中的小写变大写,大写变小写.全由文本框输出输入. 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim str As String
If Text1.Text = "" Then
MsgBox "TextBox Is Empty!"
Text1.SetFocus
Exit Sub
End If
For i = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, i, 1)) >= 65 And Asc(Mid(Text1.Text, i, 1)) <= 90 Then
str = str + LCase(Mid(Text1.Text, i, 1))
Else
str = str + UCase(Mid(Text1.Text, i, 1))
End If
Next i
Label1.Caption = str
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
==========
你这里wz用的比较乱
Dim i As Integer
Dim str As String
If Text1.Text = "" Then
MsgBox "TextBox Is Empty!"
Text1.SetFocus
Exit Sub
End If
For i = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, i, 1)) >= 65 And Asc(Mid(Text1.Text, i, 1)) <= 90 Then
str = str + LCase(Mid(Text1.Text, i, 1))
Else
str = str + UCase(Mid(Text1.Text, i, 1))
End If
Next i
Label1.Caption = str
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
==========
你这里wz用的比较乱
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询