十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Open "C:\test.txt" For Input As #1
网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了安龙免费建站欢迎大家使用!
Buffer = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
Buffer = Split(Buffer, vbNewLine)
For j = 0 To UBound(Buffer) - 1
For k = j + 1 To UBound(Buffer)
NumJ = Split(Buffer(j), vbTab)
NumX = Split(Buffer(k), vbTab)
If Val(NumJ(1)) Val(NumX(1)) Then
Temp = Buffer(j)
Buffer(j) = Buffer(k)
Buffer(k) = Temp
End If
Next k
Next j
For z = 0 To UBound(Buffer)
Print Buffer(z)
Next z
已帮你搞定!需要注意中间必须用TAB分割,不要用空格
Option Base 1
Private Sub Sort(a())
Dim Start As Integer
Dim Finish As Integer, i%, j%, t%
Start = LBound(a)
Finish = UBound(a)
For i = Finish - 1 To 2 Step -1
For j = 1 To i
If a(j) a(j + 1) Then
t = a(j + 1)
a(j + 1) = a(j)
a(j) = t
End If
Next j
Next i
End Sub
Private Sub Command1_Click()
Dim arr()
arr = Array(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text))
Sort arr
Text1.Text = arr(1)
Text2.Text = arr(2)
Text3.Text = arr(3)
Text4.Text = arr(4)
End Sub
注:原题目有错
在SQL语句中:
SQL = "Select * Form 数据表名称 Where 筛选条件 Order BY 满意度 Desc"
后面的 “Order BY 满意度 Desc”就是排序方式,按那个字段排序就在BY后面写该字段名, Desc 是降序排列,如果升序,去掉 Desc 即可。
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