使用一個單重的循環(huán)掃描這個字符串中的所有字符,對每一個字符的出現(xiàn)次數(shù)進行統(tǒng)計,最后輸出每個字符的出現(xiàn)次數(shù)。
十年的滄源網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整滄源建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“滄源網(wǎng)站設(shè)計”,“滄源網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
Private Sub Command1_Click()
s = InputBox("請輸入一個英文字符串:")
Dim a(128) As Integer
For i = 1 To Len(s)
t = Asc(Mid(s, i, 1))
a(t) = a(t) + 1
Next i
For i = 1 To 127
If a(i) 0 Then Print Chr(i); ":"; a(i)
Next i
End Sub
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim g() As Char = a.ToCharArray
Dim MyRandom As New Random
Dim bs As String = ""
For i = 1 To 20
bs = g(MyRandom.Next(0, g.GetUpperBound(0) + 1))
Next
Dim gs() As String = (From mt As Match In Regex.Matches(bs, "[A-Z]") Select mt.Value).ToArray
System.Array.Sort(gs)
gs = (From mt As Match In Regex.Matches(Join(gs, ""), "([A-Z])\1*") Select mt.Value).ToArray
Dim g_len() As Integer
g_len = (From mt As Match In Regex.Matches(Join(gs, ""), "([A-Z])\1*") Select mt.Length).ToArray ' 使用數(shù)組元素作為計數(shù)器g_len
System.Array.Sort(g_len, gs)
Label1.Text = "出現(xiàn)次數(shù)最多的字母:" gs(gs.GetUpperBound(0)).Substring(0, 1) " 共出現(xiàn)" g_len(g_len.GetUpperBound(0)) "次" vbCrLf "沒有出現(xiàn)的字母是:" Join(a.Split(bs.ToCharArray), "")
End Sub
End Class
定義一個全局的靜態(tài)變量,例如
Dim Shared c As Integer
在 button 的 click 時間里寫入 c = c + 1
這個 c 就是 點擊次數(shù)了
Dim str1 As String = "112113114111"
Dim str2 As String = "11"
Dim count As Integer = 0
For i As Integer = 0 To str1.Length - 1
Dim f As Integer = str1.IndexOf(str2, i)
If f -1 Then
MsgBox("str2出現(xiàn)在str1的" f "個字符位置")
i = f
count += 1
End If
Next
MsgBox("統(tǒng)計出str1中共有" count "個str2!")
當前名稱:vb點虐
次數(shù) vbnet randomize
分享鏈接:http://vcdvsql.cn/article0/ddsieoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、、電子商務(wù)、做網(wǎng)站、企業(yè)建站、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)