VB编程实例

VB编程实例,第1张

哦,你要多大的程序???

'初学vb的经典入门程序如下

'画三个文本框,text属性设为空

'画四command按钮,capition属性分别设为“+”“-”“*”“/”

'把以下代码复制到代码窗口,运行,为text1,text2输入数字,任意点击一个按钮看看

Private

Sub

Command1_Click()'这个叫click事件,用于鼠标单击时响应

Text3.Text

=

Val(Text1.Text)

+

Val(Text2.Text)

'command1("+")被点时运行这里

End

Sub

Private

Sub

Command2_Click()

Text3.Text供海垛剿艹济讹汐番搂

=

Val(Text1.Text)

-

Val(Text2.Text)

'(-)被点时运行这里

End

Sub

Private

Sub

Command3_Click()

Text3.Text

=

Val(Text1.Text)

*

Val(Text2.Text)

'command3("*")被点时运行这里

End

Sub

Private

Sub

Command4_Click()

Text3.Text

=

Val(Text1.Text)

/

Val(Text2.Text)

'command4("/")被点时运行这里

End

Sub

Private Sub Form_Activate()

'1年期2.25%,2年期2.43%,3年期为2.70%,5年期为2.88%(不记复利)。今有X元,5年以后使用,共有如下6中存法:

Const x1 As Double = 0.0225, x2 As Double = 0.0243, x3 As Double = 0.027, x5 As Double = 0.0288

Dim x As Double

x = Val(InputBox(""))

Print "①存一次5年期,5年后到期的本息合计"ss(x, 5, x5)

Print "②存一次3年期,一次2年期,5年后到期的本息合计"ss(ss(x, 3, x3), 2, x2)

Print "③存一次3年期,两次1年期,5年后到期的本息合计"ss(ss(ss(x, 3, x3), 1, x1), 1, x1)

Print "④存两次2年期,一次1年期,5年后到期的本息合计"ss(ss(ss(x, 2, x2), 2, x2), 1, x1)

Print "⑤存一次2年期,三次1年期,5年后到期的本息合计"ss(ss(ss(ss(x, 2, x2), 1, x1), 1, x1), 1, x1)

Print "⑥存五次1年期,5年后到期的本息合计"ss(ss(ss(ss(ss(x, 1, x1), 1, x1), 1, x1), 1, x1), 1, x1)

End Sub

Private Function ss(ByVal a As Double, b As Integer, c As Double) As Double

ss = a + a * c * b

End Function

Private Sub Form_Load()

AutoRedraw = True

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11032560.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存