加了单引号就是一个常量字符串了,对于每一行都是一样的
成都创新互联网站建设公司,提供网站设计制作、成都网站制作,网页设计,建网站,PHP网站建设等专业做网站服务;可快速的进行网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,是专业的做网站团队,希望更多企业前来合作!
像这种放在最前面的字段,order by 1 就可以了
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
如果五个号码为数组元素(1)到(5),正确的排序过程:
对于i = 1至4
对于L = 1到5 - 如果A(L)(L +1)
N = A(L)
A(L),= A(L +1)
(L +1) =
结束如果下一页l
接下来,我
能够到第一台计算机来验证结果,然后分析程序。
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim N As Integer = 9
Randomize()
Dim xx(9) As Integer
For i As Integer = 0 To N
xx(i) = Int(Rnd() * 1000) '产生 [0,1000) 之间的整数
Next
For i As Integer = 0 To N - 1
For j As Integer = i + 1 To N
If xx(i) xx(j) Then
Dim temp As Integer = 0
temp = xx(i) : xx(i) = xx(j) : xx(j) = temp
End If
Next
Next
Dim sum As Integer = 0
For i As Integer = 0 To N
TextBox1.Text += xx(i) vbCrLf
sum += xx(i)
Next
TextBox1.Text += "最大值:" xx(9) vbCrLf "最小值:" xx(0) vbCrLf "平均值:" sum / 10
End Sub
End Class
窗体上添加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
建议用 DataGridView(你用的是它吧?)内建的排序方法来排序。介绍和示例代码可以参考MSDN: