展开全部
Private Sub Command1_Click()
Dim s As Variant
Dim a(3) As Single
Dim i As Integer
Dim t21 As Single, t22 As Single
Dim t31 As Single, t32 As Single
s = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(s)
a(i + 1) = Val(s(i))
Next i
t21 = (a(1) + a(2)) / 2
t22 = (a(2) + a(3)) / 2
t31 = a(2) / t21
t32 = a(3) / t22
Text2.Text = t21 & vbCrLf & t22
Text3.Text = t31 & vbCrLf & t32
End Sub
Dim s As Variant
Dim a(3) As Single
Dim i As Integer
Dim t21 As Single, t22 As Single
Dim t31 As Single, t32 As Single
s = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(s)
a(i + 1) = Val(s(i))
Next i
t21 = (a(1) + a(2)) / 2
t22 = (a(2) + a(3)) / 2
t31 = a(2) / t21
t32 = a(3) / t22
Text2.Text = t21 & vbCrLf & t22
Text3.Text = t31 & vbCrLf & t32
End Sub
追问
结果数字后面的小数要保留四位数,怎么写代码加上?
追答
Text2.Text = Format(t21, "0.0000") & vbCrLf & Format(t22, "0.0000")
Text3.Text = Format(t31, "0.0000") & vbCrLf & Format(t32, "0.0000")
展开全部
dim a() as string,L0 as double,L1 as double,R0 as double,R1 as double
a=split(text1.text,vbcrlf)
L0=(cval(a(0))+cval(a(1)))/2
R0=cval(a(1))/L0
L1=(cval(a(1))+cval(a(2)))/2
R1=cval(a(2))/L1
Text2.text=L0 & vbcrlf & L1
Text3.text=R0 & Vbcrlf & R1
a=split(text1.text,vbcrlf)
L0=(cval(a(0))+cval(a(1)))/2
R0=cval(a(1))/L0
L1=(cval(a(1))+cval(a(2)))/2
R1=cval(a(2))/L1
Text2.text=L0 & vbcrlf & L1
Text3.text=R0 & Vbcrlf & R1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是需要求和的吗?试试下面的代码
Private Sub Command1_Click()
Dim str
Dim a(3) As Double
str = Text1
str = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(str)
a(i) = CDbl(str(i))
Next i
Text2 = a(0) + a(1)
Text3 = a(1) + a(2)
End Sub
Private Sub Command1_Click()
Dim str
Dim a(3) As Double
str = Text1
str = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(str)
a(i) = CDbl(str(i))
Next i
Text2 = a(0) + a(1)
Text3 = a(1) + a(2)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询