程序哪有问题,程序如下:
private sub command1_click()
dim k,m,a(i)
for i= 0 to 9
a(i)=text1.text(i)
next i
i=0
m=8
do
do
if a(i)>a(i+1) then
k=a(i)
a(i)=a(i+1)
a(i+1)=a(i)
end if
i=i+1
loop while i<=m
i=0
m=m-1
loop while m>0
for i=0 to 9
text2.text(i)=a(i)
next i
end sub
十分感谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 个解决方案
#1
text1.text(i)应为text1(i).text
text2.text(i)应为text2(i).text
text2.text(i)应为text2(i).text
#2
定义时,不能用a(i),i 应用数字代
#3
a(i+1)=a(i)
改为a(i+1)=k
改为a(i+1)=k
#4
up
#5
'修改后的代码:
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#6
严重关注!
#7
这样也不行呀
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#8
这样有什么问题吗?
结果不对,还是程序出错?
结果不对,还是程序出错?
#9
'以下例子演示如何打开一个应用程序并等待执行完毕,之后关闭自己。
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Dim pID As Long
Function StillRun(ByVal ProgramID) As Boolean
Dim lHProgram As Long
Dim lReturn As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
StillRun = True
Else
StillRun = False
End If
CloseHandle hProgram
End Function
Private Sub Form_Load()
If Dir$("c:\windows\cdplayer.exe") <> "" Then
Me.Show
pID = Shell("c:\windows\cdplayer.exe")
While StillRun(pID)
DoEvents
Wend
End
Else
MsgBox "没有找到CD播放器"
End
End If
End Sub
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Dim pID As Long
Function StillRun(ByVal ProgramID) As Boolean
Dim lHProgram As Long
Dim lReturn As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
StillRun = True
Else
StillRun = False
End If
CloseHandle hProgram
End Function
Private Sub Form_Load()
If Dir$("c:\windows\cdplayer.exe") <> "" Then
Me.Show
pID = Shell("c:\windows\cdplayer.exe")
While StillRun(pID)
DoEvents
Wend
End
Else
MsgBox "没有找到CD播放器"
End
End If
End Sub
#10
结果不对,最大的总在第二个
#11
Loop While m > 0
改为
Loop While m >= 0
改为
Loop While m >= 0
#12
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m >= 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m >= 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#13
up
#14
up
#15
up
#16
一个很简单的例子:
Private Sub command1_click()
Dim i As Long
Dim temp, a(9) As Long
For i = 0 To 9
a(i) = Val(Text1(i).Text)
Next i
For j = 0 To UBound(a) - 1
For k = 0 To UBound(a) - 1 - j
If a(k) > a(k + 1) Then
temp = a(k)
a(k) = a(k + 1)
a(k + 1) = temp
End If
Next
Next
For i = 0 To 9
Text2(i).Text = a(i)
Next
End Sub
Private Sub Form_Load()
Text1(0).Text = 2
Text1(1).Text = 5
Text1(2).Text = 9
Text1(3).Text = 4
Text1(4).Text = 8
Text1(5).Text = 7
Text1(6).Text = 3
Text1(7).Text = 6
Text1(8).Text = 1
Text1(9).Text = 0
End Sub
Private Sub command1_click()
Dim i As Long
Dim temp, a(9) As Long
For i = 0 To 9
a(i) = Val(Text1(i).Text)
Next i
For j = 0 To UBound(a) - 1
For k = 0 To UBound(a) - 1 - j
If a(k) > a(k + 1) Then
temp = a(k)
a(k) = a(k + 1)
a(k + 1) = temp
End If
Next
Next
For i = 0 To 9
Text2(i).Text = a(i)
Next
End Sub
Private Sub Form_Load()
Text1(0).Text = 2
Text1(1).Text = 5
Text1(2).Text = 9
Text1(3).Text = 4
Text1(4).Text = 8
Text1(5).Text = 7
Text1(6).Text = 3
Text1(7).Text = 6
Text1(8).Text = 1
Text1(9).Text = 0
End Sub
#1
text1.text(i)应为text1(i).text
text2.text(i)应为text2(i).text
text2.text(i)应为text2(i).text
#2
定义时,不能用a(i),i 应用数字代
#3
a(i+1)=a(i)
改为a(i+1)=k
改为a(i+1)=k
#4
up
#5
'修改后的代码:
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#6
严重关注!
#7
这样也不行呀
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m > 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#8
这样有什么问题吗?
结果不对,还是程序出错?
结果不对,还是程序出错?
#9
'以下例子演示如何打开一个应用程序并等待执行完毕,之后关闭自己。
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Dim pID As Long
Function StillRun(ByVal ProgramID) As Boolean
Dim lHProgram As Long
Dim lReturn As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
StillRun = True
Else
StillRun = False
End If
CloseHandle hProgram
End Function
Private Sub Form_Load()
If Dir$("c:\windows\cdplayer.exe") <> "" Then
Me.Show
pID = Shell("c:\windows\cdplayer.exe")
While StillRun(pID)
DoEvents
Wend
End
Else
MsgBox "没有找到CD播放器"
End
End If
End Sub
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Dim pID As Long
Function StillRun(ByVal ProgramID) As Boolean
Dim lHProgram As Long
Dim lReturn As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
StillRun = True
Else
StillRun = False
End If
CloseHandle hProgram
End Function
Private Sub Form_Load()
If Dir$("c:\windows\cdplayer.exe") <> "" Then
Me.Show
pID = Shell("c:\windows\cdplayer.exe")
While StillRun(pID)
DoEvents
Wend
End
Else
MsgBox "没有找到CD播放器"
End
End If
End Sub
#10
结果不对,最大的总在第二个
#11
Loop While m > 0
改为
Loop While m >= 0
改为
Loop While m >= 0
#12
Private Sub command1_click()
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m >= 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
Dim i As Long
Dim k, m, a(9) As Long
For i = 0 To 9
a(i) = Text1(i).Text
Next i
i = 0
m = 8
Do
Do
If a(i) > a(i + 1) Then
k = a(i)
a(i) = a(i + 1)
a(i + 1) = k
End If
i = i + 1
Loop While i <= m
i = 0
m = m - 1
Loop While m >= 0
For i = 0 To 9
Text2(i).Text = a(i)
Next i
End Sub
#13
up
#14
up
#15
up
#16
一个很简单的例子:
Private Sub command1_click()
Dim i As Long
Dim temp, a(9) As Long
For i = 0 To 9
a(i) = Val(Text1(i).Text)
Next i
For j = 0 To UBound(a) - 1
For k = 0 To UBound(a) - 1 - j
If a(k) > a(k + 1) Then
temp = a(k)
a(k) = a(k + 1)
a(k + 1) = temp
End If
Next
Next
For i = 0 To 9
Text2(i).Text = a(i)
Next
End Sub
Private Sub Form_Load()
Text1(0).Text = 2
Text1(1).Text = 5
Text1(2).Text = 9
Text1(3).Text = 4
Text1(4).Text = 8
Text1(5).Text = 7
Text1(6).Text = 3
Text1(7).Text = 6
Text1(8).Text = 1
Text1(9).Text = 0
End Sub
Private Sub command1_click()
Dim i As Long
Dim temp, a(9) As Long
For i = 0 To 9
a(i) = Val(Text1(i).Text)
Next i
For j = 0 To UBound(a) - 1
For k = 0 To UBound(a) - 1 - j
If a(k) > a(k + 1) Then
temp = a(k)
a(k) = a(k + 1)
a(k + 1) = temp
End If
Next
Next
For i = 0 To 9
Text2(i).Text = a(i)
Next
End Sub
Private Sub Form_Load()
Text1(0).Text = 2
Text1(1).Text = 5
Text1(2).Text = 9
Text1(3).Text = 4
Text1(4).Text = 8
Text1(5).Text = 7
Text1(6).Text = 3
Text1(7).Text = 6
Text1(8).Text = 1
Text1(9).Text = 0
End Sub