vb.net數(shù)字個(gè)數(shù) vb字符個(gè)數(shù)

VB.NET中隨機(jī)產(chǎn)生十個(gè)數(shù)字

添加listbox1,label1,command1

創(chuàng)新互聯(lián)是一家從事企業(yè)網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)站建設(shè)、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)制作的專業(yè)網(wǎng)站設(shè)計(jì)公司,擁有經(jīng)驗(yàn)豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計(jì)人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實(shí)力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨(dú)特的設(shè)計(jì)風(fēng)格。自公司成立以來曾獨(dú)立設(shè)計(jì)制作的站點(diǎn)數(shù)千家。

Public Class Form1

Dim N(10) As Integer

'生成隨機(jī)數(shù)

Private Sub CreatRand()

Dim I As Integer

Dim Strarr As String

Strarr = ""

ListBox1.Items.Clear()

Dim R As New System.Random

For I = 0 To 9

N(I) = R.Next(30, 100)

ListBox1.Items.Add(Str(N(I)))

Strarr = Strarr Str(N(I)) " "

Next

'添加標(biāo)簽的橫向數(shù)字序列

Label1.Text = Strarr

End Sub

'獲取最大值

Private Function GetMax() As Integer

Dim I As Integer

Dim intMax As Integer

intMax = 0

For I = 0 To 9

intMax = IIf(intMax N(I), intMax, N(I))

Next

Return intMax

End Function

'獲取最小值

Private Function GetMin() As Integer

Dim I As Integer

Dim intMin As Integer

intMin = 101

For I = 0 To 9

intMin = IIf(intMin N(I), intMin, N(I))

Next

Return intMin

End Function

'獲取平均值

Private Function GetAve() As Single

Dim I As Integer

Dim Sum As Integer

Sum = 0

For I = 0 To 9

Sum = Sum + N(I)

Next

Return Sum / 10

End Function

'生成隨機(jī)數(shù),顯示各種值

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Call CreatRand()

MsgBox("最大值=" Str(GetMax()) ",最小值=" Str(GetMin()) ",平均值=" Str(GetAve()))

End Sub

End Class

VB.NET ,文本框限制輸入數(shù)字個(gè)數(shù)。例如不低于5位數(shù)而不大于11位數(shù)。違反則有提示。

input type="text" maxlength="11" /這是控制最大輸入字?jǐn)?shù)至于不能少于11個(gè)字,需要在點(diǎn)擊保存按鈕時(shí),通過.length來控制

vb.net.問題:通過文本框輸入一串字符,單擊命令按鈕,要求分別統(tǒng)計(jì)字符串中所含字母和數(shù)字的個(gè)數(shù)。

要改成這樣;

for i = 1 to Len(s)

j = Mid(s,i,1)

select case j

case "a" to "z","A" to "Z"

C = C + 1

CASE "0" TO "9"

D = D + 1

CASE ELSE

M= M+1

END SELECT

NEXT

標(biāo)題名稱:vb.net數(shù)字個(gè)數(shù) vb字符個(gè)數(shù)
文章URL:http://www.muchs.cn/article22/hggecc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站排名企業(yè)建站、虛擬主機(jī)、App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管