統計VB窗體裡特定文字框的個數,VB下統計字串中所含某字元的個數

2022-03-25 08:49:51 字數 3977 閱讀 9189

1樓:

visual basic 6.0具有豐富的資料型別和眾多的內部函式。其採用模組化和結構化程式設計語言,結構清晰,語法簡單,容易學習。其中統計vb窗體裡特定文字框的個數的方法為:

1、首先,我們繪製乙個命令按鈕,並雙擊進入。

2、然後我們輸入要顯示的窗體。

3、然後輸入【.show】方法。

4、接下來我們就可以執行測試。

5、點選後,我們便可以看到第二個窗體。

注意事項:visual basic 6.0利用資料控制項可以訪問access、foxpro等多種資料庫系統,也可以訪問excel、lotus等多種電子**。

2樓:砍侃看

dim num as integer

num=0

for i=0 to 99

if text1(i).text="完成" thennum=num+1

end if

next

最終num中就是「完成」的個數

3樓:陳義軍

dim otext as textbox

dim icount as integer『遍歷文字框

for each otext in me.text1if otext.text="完成" thenicount=icount+1

next

vb下統計字串中所含某字元的個數

4樓:四捨**入

首先保證窗體上有乙個標籤label1,乙個按鈕command1,乙個文字框text1

private sub command1_click()

dim ii as integer, ccount as integer

for ii = 1 to len(text1)

if mid(text1, ii, 1) = "e" then ccount = ccount + 1

next ii

label1.caption = "共有" & count & "個e"

end sub

擴充套件資料:

字串函式(string processing function)也叫字串處理函式,指的是程式語言中用來進行字串處理的函式,如c,pascal,visual以及lotusscript中進行字串拷貝,計算長度,字元查詢等的函式。

visual basic

定位函式

instr,instrrev,instrb

擷取函式

mid,right,left

替換函式

replace

分割函式

split

格式化輸出

format

比較函式

strcomp,like

長度計算

len,lenb

編碼轉換

strconv

大小寫轉換

lcase,ucase

重複產生

string,space

5樓:巴哥泡泡

n=(len(text1.text)-len(replace(text1.text,"e","")))/len("e")

如果e是變數,那麼取消雙引號!

如果要用for的形式

n=0for i=1 to len(text1.text)-1if mid(text1.text,i,len("e"))="e" then n=n+1

next i

label1.caption= n

同樣如上!

或者dim a() as string

a = split(text1.text, "e")label1.caption= ubound(a)

編寫vb程式,根據使用者在文字框text1中輸入的字串,統計其中數字(0~9)個數

6樓:匿名使用者

private sub command1_click()dim i%, l%, s%, n%, t%, s1%l = len(text1)

for i = 1 to l

s1 = asc(mid(text1, i, 1))select case s1

case 48 to 57

n = n + 1

case 65 to 90, 97 to 122s = s + 1

case else

t = t + 1

end select

next

print n

print s

print t

end sub

vb 怎樣統計text中某個字元個數

7樓:匿名使用者

統計某個字元的**如下:

private sub command1_click()dim i as integer, ccount as integer

for i = 1 to len(text1)if mid(text1, i, 1) = "你所需要統計的字元" then ccount = ccount + 1

next i

msgbox "共有" & count & "個e"

end sub

8樓:匿名使用者

統計字元個數

text2=len(text1)-len(replace(text1,"*",""))

要統計個數可以用len函式,在文字框的change事件裡面寫**。

9樓:

假如你的文字框是text1,label是label1private sub text1_change()dim i as long

dim s as long

s = 0

for i = 1 to len(text1.text)if mid(text1.text, i, 1) = "*" then s = s + 1

next i

label1.caption = s

end sub

用vb編寫一程式,在文字框中統計在該視窗上滑鼠單擊的次數

10樓:四捨**入

private sub form_click()dim i as integer

i=i+1

text1.text=val(text1)+1end sub

11樓:匿名使用者

dim i as integer '定義整數iprivate sub form_click() '開始窗體的單擊過程

i = i + 1 '修改i的內容

text1.text = i '將文字框的內容換成在該視窗上滑鼠單擊的次數

end sub '結束本過程

12樓:秋涵佴煊

在mousedown事件中改變統計

文字框的值,用文字框的值+1

13樓:

這個文字框是text1,如下程式:

private sub form_click()static i as long

i=i+1

text1.text=str(1)'這個str是用來吧數字轉換成字元,沒有多大用途。

end sub

14樓:冷凌稀

private sub form_click()dim i as integer

i=i+1

text1.text=val(text1)+1end sub

15樓:未來讀書會

dim i as integer

private sub form_click()i = i + 1

text1.text = i

end sub

在vb程式設計中設計程式窗體中有文字框

option explicitdim s 9 as longprivate sub mand1 click dim i as long for i 1 to 9 paixu i next text2.text for i 0 to 9 text2.text text2.text s i next e...

VB如何判定文字框裡是數學數字,MFC如何從文字框中獲取數字

coo boi 和 tianqing20wen 兩位的回答都是可以的,我估計coo boi是搞 或者遊戲的 tianqing20wen 則是搞商業軟體的 胡亂猜測 其實lz的問題很簡單,沒必要用到正規表示式,我給出其他幾個方法 1.isnumeric 比如if isnumeric text1.tex...

跪求VB的變換文字框文字的字型 字型 字型大小及顏色的程式知道

悲催啊,同樣是課程設計,怎麼你們的這個課程設計照教材的例子就能寫好7788了。我們的課程設計可比這難多了。翻翻書,這個教材上有。在屬性中找font 在其中設定 vb程式設計,在窗體上建立一文字框,通過選擇,我們可以改變文字框的字型以及字型顏色和背景顏色,執行結果 private sub option...