修改时间:2024-07-13 浏览次数:190 类型:期末考试
实现上述功能的VB程序如下,请在划线处填入合适代码。
Private Sub Command1_Click()
Dim i As Integer, n As Integer
Dim x As Single, y As Single, x1 As Single, y1 As Single
Dim d As Single, min As Single
Dim s As String, t As String
s = Text1.Text: x = 25: y = 35 'A点坐标
n = 0: min = -1: t = ""
For i = 1 To
If Mid(s, i, 1) = "," Then
n = n + 1
If Then
x1 = Val(t)
Else
y1 = Val(t)
d =
If min = -1 Then min = d
If d < min Then min = d
End If
t = ""
Else
t = t + Mid(s, i, 1)
End If
Next i
Label3.Caption = Str(min)
End Sub
图a
(提示:AVERAGEIF 函数用于返回某个区域内满足给定条件的所有单元格的平均值。例如:=AVERAGEIF(A4:A23,"水果",D4:D23)用于计算1月份所有水果的平均价格。)
Private Sub Command1_Click()
Dim m1 As String, m2 As String, sum As String ,t As String
Dim n1 As Integer, n2 As Integer, k As Integer, x As Integer
m1 = Text1.Text:m2 = Text2.Text
If Then t = m1: m1 = m2: m2 = t
x = Len(m1) - Len(m2)
Do While x > 0
m2 = "0" + m2
x = x - 1
Loop
n = Len(m1): sum = "": k = 0
Do While n > 0
n1 = Val(Mid(m1, n, 1))
n2 = Val(Mid(m2, n, 1))
sum = Str((n1 + n2 + k) Mod 2) + sum
n = n - 1
Loop
If k <> 0 Then sum = Str(k) + sum
Label4.Caption = sum
End Sub
图a
图b
试题篮