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樓:匿名使用者
我怎麼覺得我前幾天回答了這個問題呀!
用matlab語句編寫程式,要求輸入字串後顯示一
你是不是想對16進位制資料進行二進位制轉換啊,我這裡有這個程式,可以試試這個 16進位制轉10進位制 轉化方法一 a textread c a.txt s 以字元形式開啟檔案 alpha hex2dec a 16進位制轉化為10進位制數,存入alpha矩陣 16進位制轉10進位制 轉化方法二 wen...
C語言程式設計編寫程式,從鍵盤輸入字串放在字元陣列a中
include include include void inorder char array,int n int main int argc,char argv 在dev c 中編寫可用,temp陣列只是暫時存放輸入字串的,它的大小可根據你實際需要調大調小。void choise int a,in...
使用者用vb編寫程式 輸入年份和月份,程式能夠判斷其是否是閏年,那個季節,這個月多少天
將以下內容復到記事本中 然後 儲存為 form1.frm version 5.00 begin vb.form form1 caption form1 clientheight 4830 clientleft 60 clienttop 450 clientwidth 8325 linktopic f...