关于vb.net排序实验报告的信息-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

关于vb.net排序实验报告的信息

VB.NET数组的排序法?

如果你是从vb6刚过渡上vb。net,建议还是用冒泡排序法,容易理解。

创新互联服务项目包括林甸网站建设、林甸网站制作、林甸网页制作以及林甸网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,林甸网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到林甸省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

如果你正努力学习vb。net的方法,推荐一个例子如下:

Imports System

Imports System.Collections

Public Class SamplesArray

Public Class myReverserClass

Implements IComparer

' Calls CaseInsensitiveComparer.Compare with the parameters reversed.

Function Compare(x As Object, y As Object) As Integer _

Implements IComparer.Compare

Return New CaseInsensitiveComparer().Compare(y, x)

End Function 'IComparer.Compare

End Class 'myReverserClass

Public Shared Sub Main()

' Creates and initializes a new Array and a new custom comparer.

Dim myArr As [String]() = {"The", "QUICK", "BROWN", "FOX", "jumps", "over", "the", "lazy", "dog"}

Dim myComparer = New myReverserClass()

' Displays the values of the Array.

Console.WriteLine("The Array initially contains the following values:")

PrintIndexAndValues(myArr)

' Sorts a section of the Array using the default comparer.

Array.Sort(myArr, 1, 3)

Console.WriteLine("After sorting a section of the Array using the default comparer:")

PrintIndexAndValues(myArr)

' Sorts a section of the Array using the reverse case-insensitive comparer.

Array.Sort(myArr, 1, 3, myComparer)

Console.WriteLine("After sorting a section of the Array using the reverse case-insensitive comparer:")

PrintIndexAndValues(myArr)

' Sorts the entire Array using the default comparer.

Array.Sort(myArr)

Console.WriteLine("After sorting the entire Array using the default comparer:")

PrintIndexAndValues(myArr)

' Sorts the entire Array using the reverse case-insensitive comparer.

Array.Sort(myArr, myComparer)

Console.WriteLine("After sorting the entire Array using the reverse case-insensitive comparer:")

PrintIndexAndValues(myArr)

End Sub 'Main

Public Shared Sub PrintIndexAndValues(myArr() As [String])

Dim i As Integer

For i = 0 To myArr.Length - 1

Console.WriteLine(" [{0}] : {1}", i, myArr(i))

Next i

Console.WriteLine()

End Sub 'PrintIndexAndValues

End Class 'SamplesArray

'This code produces the following output.

'

'The Array initially contains the following values:

' [0] : The

' [1] : QUICK

' [2] : BROWN

' [3] : FOX

' [4] : jumps

' [5] : over

' [6] : the

' [7] : lazy

' [8] : dog

'

'After sorting a section of the Array using the default comparer:

' [0] : The

' [1] : BROWN

' [2] : FOX

' [3] : QUICK

' [4] : jumps

' [5] : over

' [6] : the

' [7] : lazy

' [8] : dog

'

'After sorting a section of the Array using the reverse case-insensitive comparer:

' [0] : The

' [1] : QUICK

' [2] : FOX

' [3] : BROWN

' [4] : jumps

' [5] : over

' [6] : the

' [7] : lazy

' [8] : dog

'

'After sorting the entire Array using the default comparer:

' [0] : BROWN

' [1] : dog

' [2] : FOX

' [3] : jumps

' [4] : lazy

' [5] : over

' [6] : QUICK

' [7] : the

' [8] : The

'

'After sorting the entire Array using the reverse case-insensitive comparer:

' [0] : the

' [1] : The

' [2] : QUICK

' [3] : over

' [4] : lazy

' [5] : jumps

' [6] : FOX

' [7] : dog

' [8] : BROWN

vb.net的随机3个数字,然后排序一下

给你一个最简单的冒泡排序代码:

将三个数放到一个数组中。

a(0)=val(text1.text):a(1)=val(text2.text):a(2)=val(text3.text)

dim flag as Boolean,temp as Integer

for i = 0 to 2

flag = true

for j = 2 to 1

if a(j)a(j-1) then

temp = a(j-1)

a(j-1) = a(j)

a(j) = temp

flag = false

end if

next j

if flag then Exit For

next i

text4.text=a(0):text5.text=a(1):text6.text=a(2)

vb.net 如何对数据库查询结果记录集排序?

加了单引号就是一个常量字符串了,对于每一行都是一样的

像这种放在最前面的字段,order by 1 就可以了

VB.NET 2维数组排序排序和赋值问题

窗体上添加3个标签,1个按钮,在按钮的单击事件里写代码,如下:

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

Dim a(,) As Integer = {{5, 6}, {1, 3}, {8, 9}, {72, 1}, {63, 4}}

Dim Temp As Integer

Dim i As Integer

Dim j As Integer

Dim x As Integer

Dim y As Integer

'显示排序前的数据

Label1.Text = "排序前数据:" vbCrLf

For i = 0 To 4

Label1.Text = Label1.Text a(i, 0) " " a(i, 1) vbCrLf

Next

For i = 0 To 3

For j = i + 1 To 4

If a(i, 0) a(j, 0) Then

Temp = a(i, 0)

a(i, 0) = a(j, 0)

a(j, 0) = Temp

Temp = a(i, 1)

a(i, 1) = a(j, 1)

a(j, 1) = Temp

End If

Next

Next

'显示排序前的数据

Label2.Text = "排序后数据:" vbCrLf

For i = 0 To 4

Label2.Text = Label2.Text a(i, 0) " " a(i, 1) vbCrLf

Next

'把第3行元素赋予X,Y

x = a(2, 0)

y = a(2, 1)

'输出X,Y

Label3.Text = "X=" x vbCrLf "Y=" y

End Sub

在VB.net中,如何把listbox中的数值进行排序

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ListBox1.Items.Add("Apple")

ListBox1.Items.Add("Cat")

ListBox1.Items.Add("Yellow")

ListBox1.Items.Add("Guilty")

End Sub

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

ListBox1.Sorted = True

End Sub

End Class

VB.NET 找出数组中相同的元素,并按相同元素排序到另外一个数组中。

先把strA排序,

ind = 2

if len(strA) = 0 then return

strB(1) = strA(1)

for each s in strA

if (strA(ind) strA(ind - 1) then

count = 0

strB(ind) = strA(ind)

else

strB(ind) = strA(ind - 1)

end if

ind = ind + 1

next s

vb语法忘了。。。大概是这么个意思吧。。。。 排序N LOG N,后面是线性的N,所以总共是NLOGN


网站标题:关于vb.net排序实验报告的信息
网站URL:http://kswsj.cn/article/hgjeoi.html

其他资讯