1樓:
遍歷字串,比較其ascii,分別用不同的變數
參考**
dim intnumber as integer, intucase as integer, intlcase as integer, intspace as integer
dim i as integer, strtmp as string
intnumber = 0
intucase = 0
intlcase = 0
intspace = 0
for i = 1 to len(text1.text)
strtmp = mid(text1.text, i, 1)
if asc(strtmp) > 47 and asc(strtmp) < 58 then intnumber = intnumber + 1
if asc(strtmp) > 64 and asc(strtmp) < 91 then intucase = intucase + 1 '大寫字母個數
if asc(strtmp) > 96 and asc(strtmp) < 123 then intlcase = intlcase + 1
if asc(strtmp) = 32 then intspace = intspace + 1
next
2樓:匿名使用者
option explicit
'在窗體中添一個commandbutton、一個textbox
private sub command1_click()
dim intl as long, intu as long, ints as long, intn as long, into as long
dim i as long, char as string * 1
for i = 1 to len(text1.text)
char = mid(text1.text, i, 1)
select case char
case "a" to "z": intu = intu + 1
case "a" to "z": intl = intl + 1
case "0" to "9": intn = intn + 1
case " ": ints = ints + 1
case else: into = into + 1
end select
next
msgbox "textbox中的字串統計結果:" & vbcrlf & space(2) & "大寫字母:" & intu & "個" _
& vbcrlf & space(2) & "小寫字母:" & intl & "個" _
& vbcrlf & space(2) & "數字:" & intn & "個" _
& vbcrlf & space(2) & "空格:" & ints & "個" _
& vbcrlf & space(2) & "其它字元:" & into & "個", vbokonly or vbinformation, "統計字元輸出"
end sub
3樓:匿名使用者
可以把字元遍歷一下,然後用ascii值來判斷統計,具體函式請參考msdn。
4樓:匿名使用者
我怎麼覺得我前幾天回答了這個問題呀!
1編寫程式進行字串的擷取,即從鍵盤上輸入字串st
雪龍玉龍 第一題 include include char f char s,int m,int n int main void int m,n char s1 20 printf please input m and n scanf d d m,n printf please input a st...
C語言,利用指標編寫程式 刪除字串中的某字元
你好!p,q是指標,p,q表示p,q指向的地址儲存的字元 根據程式來說 for p s,q s p 0 p if p del x q p q p puts s 首先,p作為迴圈下標,從s字串的第一位到最後一位判斷是否為刪除的字元 其次,q作為新字串s的下標,對於每一位非刪除字元,儲存下來,q下標 1...
編寫程式,從鍵盤輸入兩個字串(長度不超過字元),將兩
豪哥侃球 用c語言的話這樣編寫 include include int main char a 123 b 123 scanf s s a,b int i,la strlen a lb strlen b for i 0 i c語言是一門通用計算機程式語言,應用廣泛。c語言的設計目標是提供一種能以簡易...