vb.net数字个数 vb字符个数-成都快上网建站

vb.net数字个数 vb字符个数

VB.NET中随机产生十个数字

添加listbox1,label1,command1

创新互联是一家从事企业网站建设、做网站、网站建设、行业门户网站建设、网页设计制作的专业网站设计公司,拥有经验丰富的网站建设工程师和网页设计人员,具备各种规模与类型网站建设的实力,在网站建设领域树立了自己独特的设计风格。自公司成立以来曾独立设计制作的站点数千家。

Public Class Form1

Dim N(10) As Integer

'生成随机数

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

'添加标签的横向数字序列

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

'生成随机数,显示各种值

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 ,文本框限制输入数字个数。例如不低于5位数而不大于11位数。违反则有提示。

input type="text" maxlength="11" /这是控制最大输入字数至于不能少于11个字,需要在点击保存按钮时,通过.length来控制

vb.net.问题:通过文本框输入一串字符,单击命令按钮,要求分别统计字符串中所含字母和数字的个数。

要改成这样;

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


文章题目:vb.net数字个数 vb字符个数
文章起源:http://kswjz.com/article/hggecc.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流