大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net题目 vb试题库

VB.NET的题目哈 随机产生20个大写字母,求出现次数最多的字母及出现次数,还有求出现次数为0的字母有哪些

Imports System.Text.RegularExpressions

成都创新互联公司主营平罗网站建设的网络公司,主营网站建设方案,app开发定制,平罗h5重庆小程序开发搭建,平罗网站营销推广欢迎平罗等地区企业咨询

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 ' 使用数组元素作为计数器g_len

System.Array.Sort(g_len, gs)

Label1.Text = "出现次数最多的字母:" gs(gs.GetUpperBound(0)).Substring(0, 1) " 共出现" g_len(g_len.GetUpperBound(0)) "次" vbCrLf "没有出现的字母是:" Join(a.Split(bs.ToCharArray), "")

End Sub

End Class

用VB.NET程序编写代码

Delphi代码如下:

procedure TForm1.Button1Click(Sender: TObject);

var

购物总价:Integer;

折扣:Extended;

begin

购物总价:=StrToInt(Edit1.Text);

if 购物总价250 then

begin

折扣:=0;

end

else if 购物总价500 then

begin

折扣:=0.05;

end

else if 购物总价1000 then

begin

折扣:=0.075;

end

else if 购物总价2000 then

begin

折扣:=0.1;

end

{

此段的折扣是多少?

else if 购物总价3000 then

begin

折扣:=0.05;

end

}

else if 购物总价=3000 then

begin

折扣:=0.15;

end;

ShowMessage('您享受的折扣是:'+FloatToStr(折扣)

+' 原价:'+IntToStr(购物总价)

+' 折后总价:'+FloatToStr(购物总价*(1-折扣)));

end;

vb.net 数组显示矩阵的一道题

'这是在vb6中的代码,在vb.net中基本差不多,你可以参考一下

Private Sub cmdCommand1_Click()

Me.AutoRedraw = True

Dim Grp

Grp = Array(1, 2, 3, 4, 5)

Dim i, j As Long

Dim StrPrt As String

For i = 0 To UBound(Grp)

'i为位移量

StrPrt = ""

For j = i To UBound(Grp)

StrPrt = StrPrt Grp(j)

Next j

For j = 0 To i - 1

StrPrt = StrPrt Grp(j)

Next j

Me.Print StrPrt

Next i

End Sub

VB.NET listbox 题目

For Each i In ListBox1.Items

If ListBox2.Items.Contains(i) = False Then

ListBox3.Items.Add(i)

End If

Next

VB.NET的题目 利用随机数生成两个4*4的矩阵A~~紧急紧急

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

MsgBox(Int(Rnd() * 10))

Dim n As Integer = 4

Dim i, a As Integer

Dim r As String

Randomize()

For i = 1 To n

r = Int(Rnd() * 10)

Label1.Text = Space(n - i + 1) StrDup(i, r) + vbNewLine

Next i

For i = n To 1 Step -1

r = Int(Rnd() * 10)

Label1.Text = Space(n - i + 1) StrDup(i, r) + vbNewLine

Next i

For Each c In Label1.Text

If IsNumeric(c) Then

a += 1

End If

Next

MsgBox(a) ‘主对角线和次对角线上各元素之和

End Sub

另一个矩阵也是用同样方法.

你说的是不是这样?


文章标题:vb.net题目 vb试题库
文章分享:http://dzwzjz.com/article/hjohhg.html
在线咨询
服务热线
服务热线:028-86922220
TOP