资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb点虐 数组降序 求降序数vb

vb点虐 datagridview控件 如何点击列头进行排序的时候 第一次点击为降序 求助各路大神

DataGridView.Sort(this.dataGridViewTextBoxColumn1, ListSortDirection.Descending);降序

织金ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

DataGridView.Sort(this.dataGridViewTextBoxColumn1, ListSortDirection.Ascending);升序

dataGridViewTextBoxColumn1是列名

VB对二维数组排序

写了一个简单的例子,你可以参考一下,希望对你有帮助。

Private Sub Form_Load()

Dim A(5, 5) As Integer

Dim I, J, K As Integer

Dim Temp As Integer

Show

'生成二维数组

Randomize

For I = 0 To 5

For J = 0 To 5

A(I, J) = Int(Rnd * 90 + 10)

Print A(I, J);

Next J

Print

Next I

Print "======================="

'排序二维数组

'一维排序

For I = 0 To 5

For J = 0 To 4

For K = J + 1 To 5

If A(I, J) = A(I, K) Then

Temp = A(I, J)

A(I, J) = A(I, K)

A(I, K) = Temp

End If

Next K

Next J

Next I

'二维排序

For I = 0 To 5

For J = 0 To 4

For K = J + 1 To 5

If A(J, I) = A(K, I) Then

Temp = A(J, I)

A(J, I) = A(K, I)

A(K, I) = Temp

End If

Next K

Next J

Next I

'重新打印二维数组

For I = 0 To 5

For J = 0 To 5

Print A(I, J);

Next J

Print

Next I

End Sub

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中输入10个数并按要求进行升序排序和降序的程序

Dim AA(1 To 10) As Integer, ZGCJ(1 To 10) As Integer, ZDCJ(1 To 10) As Integer

在通用部分声明三个数组

Private Sub Command1_Click()

Text1.Text = "": Text2.Text = "": Text3.Text = ""

Text1.Text = "系统自动生成的十个数:"  vbCrLf

For I = 1 To 10

AA(I) = 0: ZGCJ(I) = 0: ZDCJ(I) = 0

Randomize

AA(I) = Int(Rnd * 90 + 10)

Text1.Text = Text1.Text  AA(I)  Space(4)

If I Mod 5 = 0 Then Text1.Text = Text1.Text  vbCrLf

ZGCJ(I) = AA(I)

ZDCJ(I) = AA(I)

Next I

End Sub

生成十个数的代码

Private Sub Command2_Click()

Text2.Text = "": Text3.Text = ""

Dim AAA As Integer, BBB As Integer

For I = 1 To 9

For J = I + 1 To 10

If ZGCJ(I)  ZGCJ(J) Then

AAA = ZGCJ(I)

ZGCJ(I) = ZGCJ(J)

ZGCJ(J) = AAA

End If

If ZDCJ(J)  ZDCJ(I) Then

BBB = ZDCJ(J)

ZDCJ(J) = ZDCJ(I)

ZDCJ(I) = BBB

End If

Next J

Next I

Text2.Text = Text2.Text  "从大到小排列:"  vbCrLf

For I = 1 To 10

Text2.Text = Text2.Text  ZGCJ(I)  Space(4)

If I Mod 5 = 0 Then Text2.Text = Text2.Text  vbCrLf

Next I

Text3.Text = Text3.Text  "从小到大排列:"  vbCrLf

For I = 1 To 10

Text3.Text = Text3.Text  ZDCJ(I)  Space(4)

If I Mod 5 = 0 Then Text3.Text = Text3.Text  vbCrLf

Next I

End Sub

排序的代码。

如果需要自己输入数字,可以这样:

'如果要自己输入数字,可以修改下面的代码

Text1.Text = "": Text2.Text = "": Text3.Text = ""

Text1.Text = "系统自动生成的十个数:"  vbCrLf

For I = 1 To 10

AA(I) = 0: ZGCJ(I) = 0: ZDCJ(I) = 0

Randomize

AA(I) = Int(Rnd * 90 + 10)

Text1.Text = Text1.Text  AA(I)  Space(4)

If I Mod 5 = 0 Then Text1.Text = Text1.Text  vbCrLf

ZGCJ(I) = AA(I)

ZDCJ(I) = AA(I)

Next I

'----------------------------修改为:

Text1.Text = "": Text2.Text = "": Text3.Text = ""

Text1.Text = "用户输入的十个数:"  vbCrLf

For I = 1 To 10

AA(I) = 0: ZGCJ(I) = 0: ZDCJ(I) = 0

AA(I) = Val(InputBox("请输入第"  I  "个数!"))

Text1.Text = Text1.Text  AA(I)  Space(4)

If I Mod 5 = 0 Then Text1.Text = Text1.Text  vbCrLf

ZGCJ(I) = AA(I)

ZDCJ(I) = AA(I)

Next I


网站题目:vb点虐 数组降序 求降序数vb
URL地址:http://cdkjz.cn/article/ddsosoh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220