vb怎樣將text1中輸入字母在text2中自動轉換成數字

時間 2021-07-01 01:21:25

1樓:匿名使用者

private sub text1_change()dim s as string, m as stringfor i = 1 to len(text1.text)m = lcase(mid(text1.text, i, 1))if asc(m) >= 97 and asc(m) <= 122 then

s = s & asc(m) - 96

else

s = s & m

end if

next

text2.text = s

end sub

2樓:匿名使用者

private sub text1_keypress(keyascii as integer)

if keyascii > 64 and keyascii < 91 then

text2 = text2 & keyascii - 64

elseif keyascii > 96 and keyascii < 123 then

text2 = text2 & keyascii - 96

elseif keyascii > 47 and keyascii < 58 then

text2 = text2 & keyascii - 48

end if

end sub

3樓:天天過節

private sub text1_change()for i = 1 to len(text1)t = mid(text1, i, 1)

if asc(ucase(t)) >= 65 then t = ltrim(str(asc(ucase(t)) - 64))

s = s & t

next

text2 = s

end sub

4樓:匿名使用者

text2.text = replace(text1.text, "a", "1")

text2.text = replace(text2.text, "b", "2")

text2.text = replace(text2.text, "c", "3")

text2.text = replace(text2.text, "d", "4")

text2.text = replace(text2.text, "e", "5")

text2.text = replace(text2.text, "f", "6")

text2.text = replace(text2.text, "g", "7")

text2.text = replace(text2.text, "h", "8")

text2.text = replace(text2.text, "i", "9")

text2.text = replace(text2.text, "j", "10")

text2.text = replace(text2.text, "k", "11")

text2.text = replace(text2.text, "l", "12")

text2.text = replace(text2.text, "m", "13")

text2.text = replace(text2.text, "n", "14")

text2.text = replace(text2.text, "o", "15")

text2.text = replace(text2.text, "p", "16")

text2.text = replace(text2.text, "q", "17")

text2.text = replace(text2.text, "r", "18")

text2.text = replace(text2.text, "s", "19")

text2.text = replace(text2.text, "t", "20")

text2.text = replace(text2.text, "u", "21")

text2.text = replace(text2.text, "v", "22")

text2.text = replace(text2.text, "w", "23")

text2.text = replace(text2.text, "x", "24")

text2.text = replace(text2.text, "y", "25")

text2.text = replace(text2.text, "z", "26")

剛學vb在文字框中輸入字元,判斷是字母還是數字字元或者其他字元我寫的有問題應該怎麼改

s是變數,不該打引號。下面是用選擇語句來處理,可能比較清晰點。private sub command1 click dim s as string s text1 if len s 1 then select case s case a to z a to z msgbox 字母 case 0 to...

vb程式設計題在文字框tet1中輸入正整數單擊

下面是簡單實現,需要帶入引數是大於等於1的正數 自己防呆 private sub command1 click 呼叫例項dim str as string msgbox return str 5 end sub private function return str number as intege...

vb程式設計題在文字框1中輸入整數n判斷其能否

console.writeline 請輸入一個整數 int n n int.parse console.readline if n 5 0 n 7 0 console.writeline n 能夠同時被5和7整除 console.read elsew console.writeline n 不能夠同...