excel中vba问题
PrivatecurrindexAsIntegerPrivateSubCheck1_Click(indexAsInteger)IfCheck1(index).Value=...
Private currindex As Integer
Private Sub Check1_Click(index As Integer)
If Check1(index).Value = 1 Then
i = Val(Text1) / 100
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
fl(index).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
Else
fl(index).Text = ""
End If
End Sub
Private Sub Command1_Click()
' If currindex > 2 Then
' currindex = 0
' End If
i = Val(Text1)
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
fl(currindex).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
currindex = currindex + 1
End Sub
Private Sub Command2_Click()
Text5.Text = ""
B = Val(Text4.Text)
Text5.Text = (B * getTotal() - B) * 0.008631526
End Sub
Private Function getTotal() As Variant
Dim i As Integer
For i = 0 To 11
If Check1(i).Value = 1 Then
MsgBox Val(fl(i).Text)
If getTotal = 0 Then
getTotal = Val(fl(i).Text)
Else
getTotal = getTotal * Val(fl(i).Text)
End If
MsgBox getTotal
End If
Next
End Function
Private Sub Form_Load()
currindex = 0
End Sub
当在excel的vba中运行这个计算器时 将text文本框组中的数值按照运行前后依次写进excel中的单元格,请问怎么实现 需要加什么语句 展开
Private Sub Check1_Click(index As Integer)
If Check1(index).Value = 1 Then
i = Val(Text1) / 100
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
fl(index).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
Else
fl(index).Text = ""
End If
End Sub
Private Sub Command1_Click()
' If currindex > 2 Then
' currindex = 0
' End If
i = Val(Text1)
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
fl(currindex).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
currindex = currindex + 1
End Sub
Private Sub Command2_Click()
Text5.Text = ""
B = Val(Text4.Text)
Text5.Text = (B * getTotal() - B) * 0.008631526
End Sub
Private Function getTotal() As Variant
Dim i As Integer
For i = 0 To 11
If Check1(i).Value = 1 Then
MsgBox Val(fl(i).Text)
If getTotal = 0 Then
getTotal = Val(fl(i).Text)
Else
getTotal = getTotal * Val(fl(i).Text)
End If
MsgBox getTotal
End If
Next
End Function
Private Sub Form_Load()
currindex = 0
End Sub
当在excel的vba中运行这个计算器时 将text文本框组中的数值按照运行前后依次写进excel中的单元格,请问怎么实现 需要加什么语句 展开
1个回答
展开全部
Private Sub Check1_Click(index As Integer)
If Check1(index).Value = 1 Then
i = Val(Text1) / 100
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
Range("a1") = i
Range("a2") = r
Range("a3") = n
Range("a4") = B
Range("b1") = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
fl(index).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
Else
fl(index).Text = ""
End If
End Sub
我给你填了点代码,你把这个代码复制过去,指定到按钮上实验看看 ,计算前的值写在a1:a4,计算后的结果写在b1
If Check1(index).Value = 1 Then
i = Val(Text1) / 100
r = Val(Text3)
n = Val(Text2)
B = Val(Text4)
Range("a1") = i
Range("a2") = r
Range("a3") = n
Range("a4") = B
Range("b1") = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
fl(index).Text = Math.Round((1 + i) ^ n * ((r * i) / 12 + 1), 3)
Else
fl(index).Text = ""
End If
End Sub
我给你填了点代码,你把这个代码复制过去,指定到按钮上实验看看 ,计算前的值写在a1:a4,计算后的结果写在b1
追问
首先很感谢你 我还想问一个问题 在我写的语句中有fl.text文本框组 我想将这些数值也写进每个单元格 应该怎么写语句?
追答
fl.text的值不是等于b1里的吗,还有必要再写到一个单元格吗?你命令个单元格让他写里面就行了嘛
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询