Private Sub Command1_Click()
創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的勐臘網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
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上建立三個(gè)textbox,分別為textbox1,textbox2,textbox3,再建立四個(gè)按鈕,分別為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中把兩個(gè)參數(shù)相乘用什么符號(hào)
vb.net中把兩個(gè)參數(shù)相乘用 * 符號(hào)來(lái)表示相乘,用 / 符號(hào)表示相除。
首先在窗體上畫(huà)兩個(gè)控件:TextBox1和Button1
TextBox1用來(lái)輸入需要計(jì)算那個(gè)數(shù)的階乘
雙擊Button1進(jìn)入輸入代碼,代碼如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Factorial As Integer = 1 '定義一個(gè)變量用來(lái)記錄階乘的結(jié)果
Dim count As Integer '定義一個(gè)變量用來(lái)記錄需要計(jì)算那個(gè)數(shù)的階乘
Dim i As Integer = 1 '定義一個(gè)數(shù)用來(lái)循環(huán)
count = Int(Val(Me.TextBox1.Text)) '把TextBox1的值賦值給count
Do While i = count '下面開(kāi)始計(jì)算階乘
Factorial = Factorial * i '計(jì)算階乘
i += 1 '自增1
Loop
MessageBox.Show(Int(Val(Me.TextBox1.Text)) "的階乘是:" Factorial, "完成", MessageBoxButtons.OK) '彈出計(jì)算結(jié)果
Catch ex As Exception '出錯(cuò)提示
MessageBox.Show(Err.Description, "出錯(cuò)了", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub