题库 高中信息

题干

在Visual Basic中,下列属于字符串的是()。
A.Val("100")B."int(100)"C.sqr(100)D.1/2^3
上一题 下一题 0.99难度 选择题 更新时间:2016-11-22 01:11:18

答案(点此获取答案解析)

同类题1

编写VB程序,实现如下功能: 单击“排序数组a”按钮Command1时,对已有数组a的数据进行升序排列,并显示在文本框Label1中;单击“显示数组b”按钮Command2时,将升序数组b的数据显示在文本框Label2中;再单击“合并a和b”按钮Command3时,对数组a和数组b升序合并到字符串中,将合并后的数据在文本框Label3中显示。(运行效果如图所示)。实现上述功能的VB代码如下, 请在划线处填入合适代码。

Dim a(1 To 6) As Integer
Dim b(1 To 6) As Integer
Private Sub Command1_Click() '对数组a中的数据进行排序
Dim i As Integer, j As Integer ,k as integer
a(1) =" 53" :a(2) =" 18:a(3)" =" 62:a(4)" =" 22:a(5)" =" 6:a(6)" = 25
s = ""
For i =" 1" To 5
k = i
For j =" i" + 1 To 6
If a(k) > a(j) Then ①
Next j
If i <> k Then
t =" a(k):" a(k) =" a(i):" a(i) = t
End If
Next i
For i =" 1" To 6
s =" s" + Str(a(i))
Next i
Label1.Caption = s
End Sub
Private Sub Command2_Click()
b(1) =" 3:" b(2) =" 8:" b(3) =" 15:" b(4) =" 27:" b(5) =" 38:" b(6) = 49
'此处部分代码省略
End Sub
Private Sub Command3_Click()
'将数组a和b中的数据逐个比较后添加到新的字符串s中,并将s在label3中显示
i =" 1:" j =" 1:" s = ""
Do While i <=" 6"     ②   j <= 6   '如果两数组都还有数据未合并
If   ③    Then
s =" s" + Str(a(i)) : i =" i" + 1
Else
s =" s" + Str(b(j)) : j =" j" + 1
End If
Loop
Do While i <= 6 '只有数组a还有数据未合并
s =" s" + Str(a(i)) : i =" i" + 1
Loop
Do While j <= 6 '只有数组b还有数据未合并
s =" s" + Str(b(j)) : j =" j" + 1
Loop
Label3.Caption = s
End Sub

同类题4

日期判断:从文本框Text1输入一个8位数字表示的日期,其中第1到4位表示年(第1位确定不为零),第5到6位表示月,第7到8位表示日。单击“判断”按钮,判断该日期是否合法,将结果依次输出到列表框List1。程序界面如下图所示:
提示:年份值符合下列两种情况之一的是闰年。
1.年份是4的倍数,但不是100的倍数;
2.年份是400的倍数。

(1)观察程序代码,可知“判断”按钮的对象名为 。(单选,填字母:
A.Text1/B.List1/C.Command1/D.Judge/E.判断)
(2)为实现上述功能,请在划线处填入合适的代码。
Private Sub Judge_Click()
Dim riqi As String, st As String
Dim year As Integer, month As Integer, day As Integer
Dim rn As Boolean, hefa As Boolean
riqi = Text1.Text
year =" Val(Mid(riqi," 1, 4))
month =" Val(Mid(riqi," 5, 2))
day =    ①     ‘第①处
st =" Str(year)" + "年" + Str(month) + "月" + Str(day) + "日"
rn = False  ‘用于判断是否为闰年
If ②  Then rn = True  ‘第②处
If year Mod 4 =" 0" And year Mod 100 <> 0 Then rn = True
hefa = True  ‘用于判断是否为合法日期
If month =" 0" Or month > 12 Then hefa = False
If day =" 0" Then hefa = False
If (month =" 1" Or month =" 3" Or month =" 5" Or month =" 7" Or  ’与下一行语句同行
month =" 8" Or month =" 10" Or month =" 12)" And day > 31 Then hefa = False
If (month =" 4" Or month =" 6" Or month =" 9" Or month = 11) ’与下一行语句同行
And day > 30 Then hefa = False
If   ③   Then hefa =" False" ’第③处,判断闰年2月的天数是否合法
If month =" 2" And Rn =" False" And day > 28 Then hefa = False
If hefa =" True" Then st =" st" + " 合法日期" Else st =" st" + " 非法日期"
List1.AddItem st
End Sub