VB急求!!!!!!!!!!!!!!!!!!!!!!!!!!!!!谢谢了
'题目1:下面程序将10个整数从大到小排序'注意:不可增加或删除程序行,也不可以更改程序结够PrivateSubForm_Click()Dimt%,m%,n%,w%Dim...
'题目1:下面程序将10个整数从大到小排序
'注意:不可增加或删除程序行,也不可以更改程序结够
Private Sub Form_Click()
Dim t%, m%, n%, w%
Dim a(10) As Integer
For m = 1 To 10
a(m) = Int(10 + Rnd() * 90)
Print a(m); " ";
Next m
Print
For m = 1 To 9
t = m
'**********FOUND**********
For n = 2 To 10
'**********FOUND**********
If a(t) > a(n) Then n = t
Next n
'**********FOUND**********
If t = m Then
w = a(m)
a(m) = a(t)
a(t) = w
End If
Next m
For m = 1 To 7
Print a(m)
Next m
End Sub
2:题目:在窗体上有两个命令按钮和一个文本框,名称分别为
' cmdstart("开始")、cmdend("结束")和Text1。
' 文本框Text1中的字符个数不超过200个。程序刚开始
' 运行时,"结束"按钮成灰色,单击"开始"按钮后,将
' 文本框Text1.text中的字符按其ASCII码值由大到小自
' 左而右重新组合,并在窗体上输出 重组后的字符串,同
' 时使"结束"按钮能响应而"开始"按钮不能响应。
''注意:不可增加或删除程序行,也不可以更改程序结构
:Private Sub Form_load()
'**********FOUND**********
Cmdend.Enabled = True
End Sub
Private Sub Cmdstart_click()
Dim n As Integer, I As Integer, j As Integer, p As Integer
Dim a(200) As String * 1, str1 As String, t As String
str1 = Text1.Text
n = Len(str1)
For I = 1 To n
a(I) = Mid(str1, I, 1)
Next I
'**********FOUND**********
For I = 0 To n - 1
p = I
For j = I + 1 To n
'**********FOUND**********
If a(p) < a(j) Then j = p
Next j
If p <> I Then t = a(I): a(I) = a(p): a(p) = t
Next I
For I = 1 To n
Print a(I);
Next I
Cmdend.Enabled = True
Cmdstart.Enabled = False
End Sub
Private Sub Cmdend_click()
End
End Sub
3:'题目:利用一个计时器、一个标签框和二个命令按钮制作
' 一个动态秒表,单击"开始"命令按钮,秒表开始计时,
' 单击"结束"命令按钮, 秒表结束计时,并在标签框显
' 示运行时间,如"运行了0小时2分10秒"。
'注意:不可增加或删除程序行,也不可以更改程序结构
Dim x As Long
Dim h As Integer, m As Integer, s As Integer
Private Sub Form_Load()
Form1.Caption = "动态秒表(小时:分:秒)"
Command1.Caption = "开始[&S]"
Command2.Caption = "结束[&E]"
Label1.Alignment = 2
Label1.Caption = "0:0:0"
Timer1.Interval = 1000
Timer1.Enabled = False
x = 0
End Sub
Private Sub Command1_Click()
'**********FOUND**********
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
'**********FOUND**********
Timer1.Enabled = True
x = 0
Label1.Caption = "运行了" + Str(h) + "小时" + Str(m) + "分" + Str(s) + "秒"
End Sub
Private Sub Timer1_Timer()
x = x + 1
h = x \ 3600
m = (x Mod 3600) \ 60
'**********FOUND**********
s = (x Mod 3600) \ 60
Label1.Caption = Str(h) + ":" + Str(m) + ":" + Str(s)
End Sub 展开
'注意:不可增加或删除程序行,也不可以更改程序结够
Private Sub Form_Click()
Dim t%, m%, n%, w%
Dim a(10) As Integer
For m = 1 To 10
a(m) = Int(10 + Rnd() * 90)
Print a(m); " ";
Next m
For m = 1 To 9
t = m
'**********FOUND**********
For n = 2 To 10
'**********FOUND**********
If a(t) > a(n) Then n = t
Next n
'**********FOUND**********
If t = m Then
w = a(m)
a(m) = a(t)
a(t) = w
End If
Next m
For m = 1 To 7
Print a(m)
Next m
End Sub
2:题目:在窗体上有两个命令按钮和一个文本框,名称分别为
' cmdstart("开始")、cmdend("结束")和Text1。
' 文本框Text1中的字符个数不超过200个。程序刚开始
' 运行时,"结束"按钮成灰色,单击"开始"按钮后,将
' 文本框Text1.text中的字符按其ASCII码值由大到小自
' 左而右重新组合,并在窗体上输出 重组后的字符串,同
' 时使"结束"按钮能响应而"开始"按钮不能响应。
''注意:不可增加或删除程序行,也不可以更改程序结构
:Private Sub Form_load()
'**********FOUND**********
Cmdend.Enabled = True
End Sub
Private Sub Cmdstart_click()
Dim n As Integer, I As Integer, j As Integer, p As Integer
Dim a(200) As String * 1, str1 As String, t As String
str1 = Text1.Text
n = Len(str1)
For I = 1 To n
a(I) = Mid(str1, I, 1)
Next I
'**********FOUND**********
For I = 0 To n - 1
p = I
For j = I + 1 To n
'**********FOUND**********
If a(p) < a(j) Then j = p
Next j
If p <> I Then t = a(I): a(I) = a(p): a(p) = t
Next I
For I = 1 To n
Print a(I);
Next I
Cmdend.Enabled = True
Cmdstart.Enabled = False
End Sub
Private Sub Cmdend_click()
End
End Sub
3:'题目:利用一个计时器、一个标签框和二个命令按钮制作
' 一个动态秒表,单击"开始"命令按钮,秒表开始计时,
' 单击"结束"命令按钮, 秒表结束计时,并在标签框显
' 示运行时间,如"运行了0小时2分10秒"。
'注意:不可增加或删除程序行,也不可以更改程序结构
Dim x As Long
Dim h As Integer, m As Integer, s As Integer
Private Sub Form_Load()
Form1.Caption = "动态秒表(小时:分:秒)"
Command1.Caption = "开始[&S]"
Command2.Caption = "结束[&E]"
Label1.Alignment = 2
Label1.Caption = "0:0:0"
Timer1.Interval = 1000
Timer1.Enabled = False
x = 0
End Sub
Private Sub Command1_Click()
'**********FOUND**********
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
'**********FOUND**********
Timer1.Enabled = True
x = 0
Label1.Caption = "运行了" + Str(h) + "小时" + Str(m) + "分" + Str(s) + "秒"
End Sub
Private Sub Timer1_Timer()
x = x + 1
h = x \ 3600
m = (x Mod 3600) \ 60
'**********FOUND**********
s = (x Mod 3600) \ 60
Label1.Caption = Str(h) + ":" + Str(m) + ":" + Str(s)
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询