加了單引號就是一個常量字符串了,對于每一行都是一樣的
成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,提供網(wǎng)站設(shè)計制作、成都網(wǎng)站制作,網(wǎng)頁設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進(jìn)行網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,是專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!
像這種放在最前面的字段,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
如果五個號碼為數(shù)組元素(1)到(5),正確的排序過程:
對于i = 1至4
對于L = 1到5 - 如果A(L)(L +1)
N = A(L)
A(L),= A(L +1)
(L +1) =
結(jié)束如果下一頁l
接下來,我
能夠到第一臺計算機(jī)來驗證結(jié)果,然后分析程序。
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) '產(chǎn)生 [0,1000) 之間的整數(shù)
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個標(biāo)簽,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
'顯示排序前的數(shù)據(jù)
Label1.Text = "排序前數(shù)據(jù):" 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
'顯示排序前的數(shù)據(jù)
Label2.Text = "排序后數(shù)據(jù):" 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(你用的是它吧?)內(nèi)建的排序方法來排序。介紹和示例代碼可以參考MSDN: