VB题目 麻烦解决 谢谢
在名称为Forml的窗体上画两个标签(名称分别为Label1和Label2,标题分别为“书名”和“作者”),两个文本框(名称分别为Text1和Text2,Text属性均为...
在名称为Forml的窗体上画两个标签(名称分别为Label1和Label2,标题分别为“书名”和“作者”), 两个文本框(名称分别为Text1和Text2,Text属性均为空白)和一个命令按钮(名称为Command1,标题为“显示”) 。 然后编写命令按钮的Click事件过程。程序运行后,在两个文本框中分别输入书名和作者,然后单击命令按钮,则在窗体的标题栏上先后显示两个文本框中的内容,如图 所示。
展开
2个回答
展开全部
Private sub Command1_Click()
if trim(text1.text)="" then
msgbox "请输入书名!"
text1.setfocus
exit sub
end if
if trim(text2.text)="" then
msgbox "请输入作者!"
text2.setfocus
exit sub
end if
me.caption =trim(text1.text) & ",作者:" & trim(text2.text)
End Sub
if trim(text1.text)="" then
msgbox "请输入书名!"
text1.setfocus
exit sub
end if
if trim(text2.text)="" then
msgbox "请输入作者!"
text2.setfocus
exit sub
end if
me.caption =trim(text1.text) & ",作者:" & trim(text2.text)
End Sub
展开全部
(1),1个command 1个listbox
cls
Private Sub Command1_Click()
Dim a(9) As Long
Dim s As Long
Dim av As Long
Dim j As Long
Randomize
j = 0
s = 0
av = 0
For i = 0 To 9
a(i) = Rnd * (100 - 60 + 1) + 60
List1.AddItem a(i)
s = s + a(i)
Next
av = s / 10
Print "平均成绩:" & av
For i = 0 To 9
If a(i) < av Then j = j + 1
Next
Print "共有" & j & "人低于平均成绩"
End Sub
(2),一个command
Private Sub Command1_Click()
Cls
Dim a() As Long
Randomize
m = Rnd * (99 - 2 + 1) + 2
ReDim a(m, m)
Dim tem As String
For i = 0 To m
tem = ""
For j = 0 To m
a(i, j) = Rnd * (99 - 0 + 1) + 0
tem = tem & " " & Format(a(i, j), "00")
Next
Print tem
Next
Dim s As Long
For i = 0 To m
s = s + a(i, i) + a(i, m - i)
Next
Print "对角线和:" & s
End Sub
(3),一个command
Private Sub Command1_Click()
Cls
Dim a() As Long
Randomize
m = Rnd * (99 - 2 + 1) + 2
n = Rnd * (99 - 2 + 1) + 2
ReDim a(m, n)
Dim tem As String
Dim temnumber As Long
Dim r As Long
Dim c As Long
temnumber = 0
For i = 0 To m
tem = ""
For j = 0 To n
a(i, j) = Rnd * (99 - 0 + 1) + 0
If a(i, j) - temnumber > 0 Then
temnumber = a(i, j)
r = i + 1
c = j + 1
End If
tem = tem & " " & Format(a(i, j), "00")
Next
Print tem
Next
Print "最大值:" & temnumber & "在" & r & "行" & c & "列"
End Sub
(4),一个command ,一个textbox
Private Sub Command1_Click()
On Error GoTo saverror
a = Int(Val(Text1.Text)) + 1
If a - 3 <= 0 Then
MsgBox ("当前" & Int(Val(Text1.Text)) & "公里,需缴费8元")
Else
MsgBox ("当前" & Int(Val(Text1.Text)) & "公里,需缴费" & (a - 3) * 1.6 & "元")
End If
Exit Sub
saverror:
Print "我没有对text限制,所以输入数字吧!"
End Sub
(5),一个command,一个text
Private Sub Command1_Click()
On Error GoTo saverror
a = Int(Val(Text1.Text))
If ((a Mod 4 = 0) And (a Mod 100 <> 0)) Or (a Mod 400 = 0) Then
MsgBox (Int(Val(Text1.Text)) & "是润年!")
Else
MsgBox (Int(Val(Text1.Text)) & "不是润年!")
End If
Exit Sub
saverror:
Print "我没有对text限制,所以输入数字吧!"
End Sub
(6),一个command
Private Sub Command1_Click()
Dim s As Long
Dim tem As Double
Dim t As Long
tem = 1
s = 1
t = 1
Do
If t = 1 Then
t = -1
Else
t = 1
End If
s = s + 2
tem = tem + t / s
Loop Until s > 103
Print tem
End Sub
End Sub
cls
Private Sub Command1_Click()
Dim a(9) As Long
Dim s As Long
Dim av As Long
Dim j As Long
Randomize
j = 0
s = 0
av = 0
For i = 0 To 9
a(i) = Rnd * (100 - 60 + 1) + 60
List1.AddItem a(i)
s = s + a(i)
Next
av = s / 10
Print "平均成绩:" & av
For i = 0 To 9
If a(i) < av Then j = j + 1
Next
Print "共有" & j & "人低于平均成绩"
End Sub
(2),一个command
Private Sub Command1_Click()
Cls
Dim a() As Long
Randomize
m = Rnd * (99 - 2 + 1) + 2
ReDim a(m, m)
Dim tem As String
For i = 0 To m
tem = ""
For j = 0 To m
a(i, j) = Rnd * (99 - 0 + 1) + 0
tem = tem & " " & Format(a(i, j), "00")
Next
Print tem
Next
Dim s As Long
For i = 0 To m
s = s + a(i, i) + a(i, m - i)
Next
Print "对角线和:" & s
End Sub
(3),一个command
Private Sub Command1_Click()
Cls
Dim a() As Long
Randomize
m = Rnd * (99 - 2 + 1) + 2
n = Rnd * (99 - 2 + 1) + 2
ReDim a(m, n)
Dim tem As String
Dim temnumber As Long
Dim r As Long
Dim c As Long
temnumber = 0
For i = 0 To m
tem = ""
For j = 0 To n
a(i, j) = Rnd * (99 - 0 + 1) + 0
If a(i, j) - temnumber > 0 Then
temnumber = a(i, j)
r = i + 1
c = j + 1
End If
tem = tem & " " & Format(a(i, j), "00")
Next
Print tem
Next
Print "最大值:" & temnumber & "在" & r & "行" & c & "列"
End Sub
(4),一个command ,一个textbox
Private Sub Command1_Click()
On Error GoTo saverror
a = Int(Val(Text1.Text)) + 1
If a - 3 <= 0 Then
MsgBox ("当前" & Int(Val(Text1.Text)) & "公里,需缴费8元")
Else
MsgBox ("当前" & Int(Val(Text1.Text)) & "公里,需缴费" & (a - 3) * 1.6 & "元")
End If
Exit Sub
saverror:
Print "我没有对text限制,所以输入数字吧!"
End Sub
(5),一个command,一个text
Private Sub Command1_Click()
On Error GoTo saverror
a = Int(Val(Text1.Text))
If ((a Mod 4 = 0) And (a Mod 100 <> 0)) Or (a Mod 400 = 0) Then
MsgBox (Int(Val(Text1.Text)) & "是润年!")
Else
MsgBox (Int(Val(Text1.Text)) & "不是润年!")
End If
Exit Sub
saverror:
Print "我没有对text限制,所以输入数字吧!"
End Sub
(6),一个command
Private Sub Command1_Click()
Dim s As Long
Dim tem As Double
Dim t As Long
tem = 1
s = 1
t = 1
Do
If t = 1 Then
t = -1
Else
t = 1
End If
s = s + 2
tem = tem + t / s
Loop Until s > 103
Print tem
End Sub
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询