1樓:健康快樂你好呀
'text2設定多行private sub command1_click()
dim i as integer, s as string, arr(1 to 5) as integer
for i = 1 to len(text1)
s = mid(text1, i, 1)
select case s
case "a" to "z": arr(1) = arr(1) + 1
case "a" to "z": arr(2) = arr(2) + 1
case " ": arr(3) = arr(3) + 1
case "0" to "9": arr(4) = arr(4) + 1
case else: arr(5) = arr(5) + 1
end select
next
text2 = "大寫:" & arr(1) & vbnewline & "小寫:" & arr(2) & vbnewline & _
"空格:" & arr(3) & vbnewline & "數字:" & arr(4) & vbnewline & _
"其它:" & arr(5)
end sub
vb程式,怎樣統計文字框中大寫英文字母、小寫英文字母及數字的個數,希望有註釋
2樓:匿名使用者
private sub form_load()
command1.enabled = false '使command1不可用
label2.visible = false '使label2、...、label7不可見
label3.visible = false
label4.visible = false: label5.visible = false
label6.visible = false: label7.visible = false
label8.visible = false: label9.visible = false
'text1.tabindex = 0 '使文字框獲得輸入焦點
end sub
private sub text1_keypress(keyascii as integer)
if keyascii = 13 then command1.enabled = 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 = text1.text
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%
label5.caption = n1: label6.caption = n2
label7.caption = n3: label2.visible = true '顯示標籤
label3.visible = true: label4.visible = true
label5.visible = true: label6.visible = true
label7.visible = 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%
label8.visible = true: label9.visible = true
label9.caption = n4
end sub
用vb程式設計統計一段英文中大寫字母、小寫字母、空格、數字以及其他字元的個數。
3樓:匿名使用者
private sub command1_click()
dim l as integer, s as string, a%, b%, c%, d%, e%
l = len(text1)
for i = 1 to l
s = mid(text1, i, 1)
select case asc(s)
case 65 to 90
a = a + 1
case 97 to 122
b = b + 1
case 32 '空格的asc為32
c = c + 1
case 48 to 57
d = d + 1
case else
e = e + 1
end select
next i
text2 = text2.text & "大寫字母個數為:" & a & chr(13) & chr(10)
text2 = text2.text & "小寫字母個數為:" & b & chr(13) & chr(10)
text2 = text2.text & "空格的個數為:" & c & chr(13) & chr(10)
text2 = text2.text & "數字的個數為:" & d & chr(13) & chr(10)
text2 = text2.text & "其他字元的個數為:" & e
end sub
4樓:匿名使用者
'text2設定多行private sub command1_click()
dim i as integer, s as string, arr(1 to 5) as integer
for i = 1 to len(text1)
s = mid(text1, i, 1)
select case s
case "a" to "z": arr(1) = arr(1) + 1
case "a" to "z": arr(2) = arr(2) + 1
case " ": arr(3) = arr(3) + 1
case "0" to "9": arr(4) = arr(4) + 1
case else: arr(5) = arr(5) + 1
end select
next
text2 = "大寫:" & arr(1) & vbnewline & "小寫:" & arr(2) & vbnewline & _
"空格:" & arr(3) & vbnewline & "數字:" & arr(4) & vbnewline & _
"其它:" & arr(5)
end sub
private sub form_load()
command1.caption = "統計"
text1 = ""
text2 = ""
end sub
vb如何計算文字框中的大寫字母,小寫字母,數字,其他字元的個數並在picture中輸出個數
5樓:匿名使用者
用ascii碼規定幾個範圍,再用條件語句判斷..程式略.....
6樓:
你的問題能說的再清楚點嗎 ?
7樓:匿名使用者
private sub command1_click()n = 0
m = 0
k = 0
l = 0
aa = 0
bb = text1
do until len(bb) = 0
aa = asc(bb)
bb = right(bb, len(bb) - 1)print aa
if 97 <= aa and aa <= 122 thenn = n + 1
else
if 65 <= aa and aa <= 90 thenm = m + 1
else
if 48 <= aa and aa <= 57 thenk = k + 1
else
l = l + 1
end if
end if
end if
loop
picture1.print "小寫字母為"; n; "個"
picture1.print "大寫字母為"; m; "個"
picture1.print "數字為"; k; "個"
picture1.print "特殊符號為"; l; "個"
end sub
vb輸入一串字串,統計並輸出其中大寫英文字母、小寫英文字母、數字和其他字元出現的次數。 10
8樓:匿名使用者
下次貼**,別貼截圖。你還指望別人練打字抄一遍嗎?
'改為print "大寫字母有:" & cstr(num1) & "個"
用vb程式設計:在文字框中輸入一個字串,統計其中的大寫英文、小寫英文、數字及其他字元各有多少個。
9樓:芝麻大咖
option explicit
private sub command1_click()dim i as integer
dim stra as string
dim a as integer
for i = 1 to len(text1.text)stra = mid(text1.text, i, 1)msgbox "當前字母為:" & stra & " 新增分析即可"
'利用asc的值區分字母數字字元等,因為要統計的太多了不多說,只教方法
' if asc(stra)= 91 thennext
end sub
vb如何設定文字框輸入只為大寫字母和數字
vb可在文字框的keypress事件中判斷鍵盤輸入字元的keyascii引數做取捨。keypress事件,此事件當使用者按下和鬆開一個 ansi 鍵時發生。private sub form load text1 end sub private sub text1 keypress keyascii ...
vb裡怎麼讓單擊後文字框擴大,同時文字框內的文字按照規定要求擴大N倍
private sub text1 click n inputbox 你要擴大幾倍?2 text1.width text1.width ntext1.height text1.height ntext1.font.size text1.font.size n end sub 請參閱我部落格中專門為回...
coreldraw中,怎麼樣拉動文字框,裡面的文字也跟著變大小
沒老婆的丈夫 轉曲再拉.不過cdr對齊方式還有很多東西值得研究。有興趣可以m我 鼬手寫愛 在左側工具箱中選中 挑選工具 功能 圖示為白色滑鼠指標 然後單擊你準備改變大小的文字,此時在文字周圍出現八個黑點,用滑鼠左鍵拖動上下左右四個黑點其中之一可以改變字型橫縱比,拖動四個角的黑點可以保持橫縱比改變文字...