VB 大小寫互換!!!!!!!

  • 作者:由 匿名使用者 發表于 攝影
  • 2023-01-24

VB 大小寫互換!!!!!!!墨未濃2012.04.03 回答

Private Sub Command1_Click()

Dim s As String, i As Integer, t, a As String

s = InputBox(“請輸入一個字串:”)

i = 1

Do While i <= Len(s)

t = Mid(s, i, 1)

If Asc(t) >= 65 And Asc(t) <= 90 Then

a = a & Chr(Asc(t) + 32)

ElseIf Asc(t) >= 97 And Asc(t) <= 122 Then

a = a & Chr(Asc(t) - 32)

Else

a = a & t

End If

i = i + 1

Loop

Print a

End Sub

VB 大小寫互換!!!!!!!愛你沒差2012.04.04 回答

private sub text1_keypress(keyascii as integer)

if keyascii < 91 and keyascii > 64 then

keyascii = keyascii + 32

elseif keyascii > 96 and keyascii < 123 then

keyascii = keyascii - 32

elseif keyascii <> 32 then

keyascii = 42

end if

end sub

VB 大小寫互換!!!!!!!匿名使用者2012.04.03 回答

建議用VB。NET 有 ToLower ToUpper

VB 大小寫互換!!!!!!!匿名使用者2012.04.03 回答

我在程式碼里加了非字母時的處理,如果不需要可以刪除

Private Sub Command2_Click()

Dim S1 As String, S2 As String, I As Long, N As Long

S1 = InputBox(“請輸入一個字串:”)

Do While Len(S1) > 0

N = Asc(S1)

If N > 64 And N < 90 Then

S2 = S2 & Chr(N + 32)

Else

If N > 96 And N < 123 Then

S2 = S2 & Chr(N - 32)

Else

S2 = S2 & Left(S1, 1)

End If

End If

S1 = Right(S1, Len(S1) - 1)

Loop

Debug。Print S2 ‘s2為變後的字串

End Sub

VB 大小寫互換!!!!!!!匿名使用者2012.04.03 回答

Private Sub Command1_Click()

For i = 0 To 128

Debug。Print Chr(i) & “ ” & i

Next i

s = “”

t = Text1。Text

For i = 0 To Len(Text1。Text) - 1

t = Mid(Text1。Text, i + 1, Len(Text1。Text) - 1)

a = Mid(t, 1, 1)

If Asc(a) >= 65 And Asc(a) <= 90 Then

s = s & LCase(a)

Else

s = s & UCase(a)

End If

Next i

Text1。Text = s

End Sub

Top