Private Sub Command1_ Click() Dim a, b, c As single Dim As Single a=Val(Text1.Text) b= Val(Tex2.Text) c=Val(Text3.Text) s=a×2.75+b*0.56+c*1.85 Text4.Caption=s End Sub |
(2)修改“s=a×2.75+b*0.56+c*1.85”行中的1处错误;
(3)修改“Text4. Caption=s”行中的1处错误;
(4)保存文件。
相似题推荐
原字符串8个字符为一段,分成若干段进行重排处理,尾段剩余字符(个数小于8)为独立段不做处理。
重排规则:从起始段第1个字符开始,从1开始数数,数到m时取出该位置上的字符,拼接到新字符串。然后,从下一个位置继续从1开始数数,数到m时再次取出相应位置上的字符,拼接到新字符串。当数到每段的最后-一个字符时,重新从该段首第一个没有取掉的字符继续数数。重复上述操作,直至段内8个字符被取完。注:当某段中的7个字符被取出后,该段最后一个字符不需要数数,直接取出拼接到新字符串即可。
用以上方法逐段取字符,直至除独立段之外的其他字符取完。
独立段字符个数小于8,不需要重排,直接拼接到新字符串的尾部即可。
实现该功能的VB程序功能如下:程序运行时从文本框Text1中输入一段字符串,在文本框Text2输入正整数m,单击“确定”按钮Command1,对字符串按上述方法重排后在文本框Text3中显示(每段以逗号分隔)。程序运行界面如下:(1)运行上述程序,若在文本框中输入“1010110010”,在Text2中输入5,单击“确定”按钮,则文本框Text3中显示的内容是
(2)实现上述功能的VB程序如下,请在划线处填入合适的代码。
Private Sub Command1_lick()
Dim s1 As String,s2 As String
Dim i As Integer,sum As Integer,ed As Integer,n As Integer
Dim m As Integer
①
s1 = Mid(Text1.Text,1,Len(Text1.Text)- n)
m = Val(Text2.Text)
s2 = " "
' 字符重排顺序
sum = 0 : i = 1 : ed = 8
Do While Len(s1)< > 0
sum = sum + 1
If sum = m Then
s2 = s2 + Mid(s1,i,1)
s1 = Mid(s1,1,i-1)+ Mid(s1,i+1,Len(s1)-i)
ed = ed – 1
sum = 0
Else
i = i + 1
End If
If ed = 1 Then
s2 = s2 + Mid(s1,1,1)+ ","
②
ed = 8
i = 1
ElseIf ③
i = 1
End If
Loop
' 处理独立段
If n < > 0 Then s2 = s2 + Mid(Text1.Text,Len(Text1.Text)- n + 1,n)+ ","
Text3.Text = s2
End Sub
Const n = 10
Dim a(1 To 100) As Integer
Dim b(1 To 100) As Integer
Private Sub Form_Load()
'随机生产10个11-99之间的数字,并依次存储在数组a中,代码略
End SubPrivate Sub Command1_Click()
Dim num As Integer, L As Integer, R As Integer, i As Integer
Dim m As Integer, f As Boolean
num = 1: b(1) = a(1)
For i = 2 To n
b(num + 1) = a(i) + 1
f = False
For j = 1 To num + 1
If a(i) < b(j) Then
Exit For
ElseIf a(i) = b(j) Then
①
End If
Next j
If Not f Then
For k =
b(k + 1) = b(k)
Next k
②
num = num + 1
End If
Next i
'最终将数组b的排序结果输出到文本框中,代码略
End Sub根据如上代码,请回答下列问题:
(1)若要清除文本框Text1中的内容,能实现该功能的语句是
(单选,填字母:A.Text1.clear / B.Text1.Text=“”/ C.Text1.Caption=“”)
(2)请在划线处填上合适的代码。
(3)程序中加框处代码有错,请改正。
改正:
(1)在程序代码中,第一行语句“Private Sub Com1_Click( )”中的Com1_Click( )是
(2)为实现上述功能,请在划线处填入合适的代码或语句。Private Sub Com1_Click()
Dim s As String, c1 As String, c2 As String
Dim n As Integer, i As Integer
Dim f As
s = Txt1.Text
n = Len(s)
f = True
For i = 1 To n \ 2
c1 = Mid(s, i, 1)
If c1 <> c2 Then
Exit For '退出For循环
End If
Next i
If f = True Then
Lab2.Caption = "对称"
Else
Lab2.Caption = "不对称"
End If
End Sub