十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Private Sub Command1_Click()
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计制作、网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的勐腊网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
Dim A, B, C
A = 10
B = 3
C = f(A) / (f(B) * f(A - B))
Print C
End Sub
Private Function f(n)
Dim I As Integer
f = 1
For I = 1 To n
f = f * I
Next I
End Function
先在form上建立三个textbox,分别为textbox1,textbox2,textbox3,再建立四个按钮,分别为cmdplus,cmdminus,cmdmultiple,cmddivide,代码如下:
Private Sub cmdplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplus.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a + b
End If
Private Sub cmdminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdminus.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a - b
End If
Private Sub cmdmultiple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdmultiple.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a * b
End If
Private Sub cmddivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddivide.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a / b
End If
vb.net中把两个参数相乘用什么符号
vb.net中把两个参数相乘用 * 符号来表示相乘,用 / 符号表示相除。
首先在窗体上画两个控件:TextBox1和Button1
TextBox1用来输入需要计算那个数的阶乘
双击Button1进入输入代码,代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Factorial As Integer = 1 '定义一个变量用来记录阶乘的结果
Dim count As Integer '定义一个变量用来记录需要计算那个数的阶乘
Dim i As Integer = 1 '定义一个数用来循环
count = Int(Val(Me.TextBox1.Text)) '把TextBox1的值赋值给count
Do While i = count '下面开始计算阶乘
Factorial = Factorial * i '计算阶乘
i += 1 '自增1
Loop
MessageBox.Show(Int(Val(Me.TextBox1.Text)) "的阶乘是:" Factorial, "完成", MessageBoxButtons.OK) '弹出计算结果
Catch ex As Exception '出错提示
MessageBox.Show(Err.Description, "出错了", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub