成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

vb.net函數(shù)計算器 vb三角函數(shù)計算器代碼

如何用VB.NET編寫計算器

簡單的說拖出一些控件,設置相應的caption和屬性等等,雙擊每個button控件,進行相應的處理,即可

成都創(chuàng)新互聯(lián)是專業(yè)的廣宗網(wǎng)站建設公司,廣宗接單;提供網(wǎng)站制作、網(wǎng)站設計,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行廣宗網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

用VB.NET編的計算器程序!

Public Class SimpleCalculator

Inherits System.Windows.Forms.Form

#Region " Windows 窗體設計器生成的代碼 "

Public Sub New()

MyBase.New()

'該調用是 Windows 窗體設計器所必需的。

InitializeComponent()

'在 InitializeComponent() 調用之后添加任何初始化

End Sub

'窗體重寫處置以清理組件列表。

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Windows 窗體設計器所必需的

Private components As System.ComponentModel.IContainer

'注意:以下過程是 Windows 窗體設計器所必需的

'可以使用 Windows 窗體設計器修改此過程。

'不要使用代碼編輯器修改它。

Friend WithEvents Label1 As System.Windows.Forms.Label

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents Button2 As System.Windows.Forms.Button

Friend WithEvents Button3 As System.Windows.Forms.Button

Friend WithEvents Button4 As System.Windows.Forms.Button

Friend WithEvents Button5 As System.Windows.Forms.Button

Friend WithEvents Button6 As System.Windows.Forms.Button

Friend WithEvents Button7 As System.Windows.Forms.Button

Friend WithEvents Button8 As System.Windows.Forms.Button

Friend WithEvents Button9 As System.Windows.Forms.Button

Friend WithEvents Button10 As System.Windows.Forms.Button

Friend WithEvents Button11 As System.Windows.Forms.Button

Friend WithEvents Button12 As System.Windows.Forms.Button

Friend WithEvents Button13 As System.Windows.Forms.Button

Friend WithEvents Button14 As System.Windows.Forms.Button

Friend WithEvents Button15 As System.Windows.Forms.Button

Friend WithEvents Button16 As System.Windows.Forms.Button

System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()

Me.Label1 = New System.Windows.Forms.Label

Me.TextBox1 = New System.Windows.Forms.TextBox

Me.Button1 = New System.Windows.Forms.Button

Me.Button2 = New System.Windows.Forms.Button

Me.Button3 = New System.Windows.Forms.Button

Me.Button4 = New System.Windows.Forms.Button

Me.Button5 = New System.Windows.Forms.Button

Me.Button6 = New System.Windows.Forms.Button

Me.Button7 = New System.Windows.Forms.Button

Me.Button8 = New System.Windows.Forms.Button

Me.Button9 = New System.Windows.Forms.Button

Me.Button10 = New System.Windows.Forms.Button

Me.Button11 = New System.Windows.Forms.Button

Me.Button12 = New System.Windows.Forms.Button

Me.Button13 = New System.Windows.Forms.Button

Me.Button14 = New System.Windows.Forms.Button

Me.Button15 = New System.Windows.Forms.Button

Me.Button16 = New System.Windows.Forms.Button

Me.SuspendLayout()

'

'Label1

'

Me.Label1.Location = New System.Drawing.Point(16, 16)

Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(48, 16)

Me.Label1.TabIndex = 0

Me.Label1.Text = "結果:"

'

'TextBox1

'

Me.TextBox1.Location = New System.Drawing.Point(64, 8)

Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(120, 21)

Me.TextBox1.TabIndex = 1

Me.TextBox1.Text = ""

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(200, 8)

Me.Button1.Name = "Button1"

Me.Button1.Size = New System.Drawing.Size(56, 24)

Me.Button1.TabIndex = 2

Me.Button1.Text = "清空"

'

'Button2

'

Me.Button2.Location = New System.Drawing.Point(48, 56)

Me.Button2.Name = "Button2"

Me.Button2.Size = New System.Drawing.Size(24, 24)

Me.Button2.TabIndex = 3

Me.Button2.Text = "1"

'

'Button3

'

Me.Button3.Location = New System.Drawing.Point(88, 56)

Me.Button3.Name = "Button3"

Me.Button3.Size = New System.Drawing.Size(24, 24)

Me.Button3.TabIndex = 4

Me.Button3.Text = "2"

'

'Button4

'

Me.Button4.Location = New System.Drawing.Point(136, 56)

Me.Button4.Name = "Button4"

Me.Button4.Size = New System.Drawing.Size(24, 24)

Me.Button4.TabIndex = 5

Me.Button4.Text = "3"

'

'Button5

'

Me.Button5.Location = New System.Drawing.Point(48, 88)

Me.Button5.Name = "Button5"

Me.Button5.Size = New System.Drawing.Size(24, 24)

Me.Button5.TabIndex = 6

Me.Button5.Text = "4"

'

'Button6

'

Me.Button6.Location = New System.Drawing.Point(88, 88)

Me.Button6.Name = "Button6"

Me.Button6.Size = New System.Drawing.Size(24, 24)

Me.Button6.TabIndex = 7

Me.Button6.Text = "5"

'

'Button7

'

Me.Button7.Location = New System.Drawing.Point(136, 88)

Me.Button7.Name = "Button7"

Me.Button7.Size = New System.Drawing.Size(24, 24)

Me.Button7.TabIndex = 8

Me.Button7.Text = "6"

'

'Button8

'

Me.Button8.Location = New System.Drawing.Point(48, 120)

Me.Button8.Name = "Button8"

Me.Button8.Size = New System.Drawing.Size(24, 24)

Me.Button8.TabIndex = 9

Me.Button8.Text = "7"

'

'Button9

'

Me.Button9.Location = New System.Drawing.Point(88, 120)

Me.Button9.Name = "Button9"

Me.Button9.Size = New System.Drawing.Size(24, 24)

Me.Button9.TabIndex = 10

Me.Button9.Text = "8"

'

'Button10

'

Me.Button10.Location = New System.Drawing.Point(136, 120)

Me.Button10.Name = "Button10"

Me.Button10.Size = New System.Drawing.Size(24, 24)

Me.Button10.TabIndex = 11

Me.Button10.Text = "9"

'

'Button11

'

Me.Button11.Location = New System.Drawing.Point(48, 152)

Me.Button11.Name = "Button11"

Me.Button11.Size = New System.Drawing.Size(24, 24)

Me.Button11.TabIndex = 12

Me.Button11.Text = "0"

'

'Button12

'

Me.Button12.Location = New System.Drawing.Point(176, 56)

Me.Button12.Name = "Button12"

Me.Button12.Size = New System.Drawing.Size(24, 24)

Me.Button12.TabIndex = 13

Me.Button12.Text = "+"

'

'Button13

'

Me.Button13.Location = New System.Drawing.Point(176, 88)

Me.Button13.Name = "Button13"

Me.Button13.Size = New System.Drawing.Size(24, 24)

Me.Button13.TabIndex = 14

Me.Button13.Text = "-"

'

'Button14

'

Me.Button14.Location = New System.Drawing.Point(176, 120)

Me.Button14.Name = "Button14"

Me.Button14.Size = New System.Drawing.Size(24, 24)

Me.Button14.TabIndex = 15

Me.Button14.Text = "*"

'

'Button15

'

Me.Button15.Location = New System.Drawing.Point(176, 152)

Me.Button15.Name = "Button15"

Me.Button15.Size = New System.Drawing.Size(24, 24)

Me.Button15.TabIndex = 16

Me.Button15.Text = "/"

'

'Button16

'

Me.Button16.Location = New System.Drawing.Point(88, 152)

Me.Button16.Name = "Button16"

Me.Button16.Size = New System.Drawing.Size(72, 24)

Me.Button16.TabIndex = 17

Me.Button16.Text = "計算"

'

'SimpleCalculator

'

Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)

Me.ClientSize = New System.Drawing.Size(264, 190)

Me.Controls.Add(Me.Button16)

Me.Controls.Add(Me.Button15)

Me.Controls.Add(Me.Button14)

Me.Controls.Add(Me.Button13)

Me.Controls.Add(Me.Button12)

Me.Controls.Add(Me.Button11)

Me.Controls.Add(Me.Button10)

Me.Controls.Add(Me.Button9)

Me.Controls.Add(Me.Button8)

Me.Controls.Add(Me.Button7)

Me.Controls.Add(Me.Button6)

Me.Controls.Add(Me.Button5)

Me.Controls.Add(Me.Button4)

Me.Controls.Add(Me.Button3)

Me.Controls.Add(Me.Button2)

Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.TextBox1)

Me.Controls.Add(Me.Label1)

Me.Name = "SimpleCalculator"

Me.Text = "簡單計算器"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub TextBox1_TabStopChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim btn As Button '按鈕類型的變量

btn = sender '把產生該事件的按鈕對象賦值給btn

TextBox1.Text = TextBox1.Text + btn.Text '把該按鈕的Text屬性值連接到TextBox1中

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

Dim btn As Button

btn = sender

'在文本框的Text屬性后連接一個空格、本按鈕的Text屬性值和一個空格

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = "" '清空文本框

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click

'發(fā)生錯誤轉移到標號“ErrorPro”指定的行去執(zhí)行錯誤處理程序

On Error GoTo ErrorPro

Dim r As Decimal '保存計算結果的變量

Dim t As String = TextBox1.Text '用于保存文本框中的算術表達式

Dim space As Integer = t.IndexOf(" ") '搜索空格位置,如果沒有空格,返回值為0

'字符串的取子符方法,第二個參數(shù)小于0,則將產生錯誤號為5的異常,即過程參數(shù)不正確

Dim s1 As String = t.Substring(0, space) '通過取子串方法獲得第一個運算數(shù)

Dim op As String = t.Substring(space + 1, 1) '通過取子串方法獲得運算符

Dim s2 As String = t.Substring(space + 3) '通過取子串方法獲得第二個運算數(shù)

Dim arg1, arg2 As Integer

arg1 = Val(s1) : arg2 = Val(s2)

Select Case op

Case "+" : r = arg1 + arg2

Case "-" : r = arg1 - arg2

Case "*" : r = arg1 * arg2

Case "/" : r = arg1 / arg2

Case Else

MsgBox("輸入的運算符有誤!")

Exit Sub

End Select

TextBox1.Text = CStr(r) '顯示結果

Exit Sub '退出過程

ErrorPro: '錯誤處理程序塊

Select Case Err.Number

Case 6 '除數(shù)為零時,或運算溢出時的錯誤號

MsgBox("算術運算溢出!", , "溢出提示")

TextBox1.Focus()

Exit Sub

Case 5 ' Substring過程的參數(shù)不符合要求的錯誤號

MsgBox("必須輸入運算符和第二個運算數(shù)!", , "運算數(shù)少")

Exit Sub

Case Else

'其它情況顯示錯誤號和錯誤原因

MsgBox("錯誤號為" Err.Number Chr(10) Chr(13) "錯誤原因:" Err.Description)

Exit Sub

End Select

End Sub

End Class

怎么個錯法?VB.net 中設計科學計算器

你是不是復制別人的代碼~~~不然你怎么看不出來問題呢,改一下控件名,跟代碼的一樣

VB.NET怎么編模擬袖珍計算器的完整程序?

Public C護激篙刻蕻灸戈熏恭抹lass Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim c As Char

c = Trim(TextBox3.Text)

Select Case c

Case "+"

TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

Case "-"

TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

Case "*"

TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

Case "\"

If Val(TextBox2.Text) = 0 Then

MsgBox("分母為0")

Else

TextBox4.Text = Val(TextBox1.Text) \ Val(TextBox2.Text)

End If

Case "/"

If Val(TextBox2.Text) = 0 Then

MsgBox("分母為0")

Else

TextBox4.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

End If

End Select

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

End

End Sub

End Class

vb:簡易計算器(加減乘除)代碼

代碼如下:

Dim t, t1 As Integer

Dim x, y As Double

Public Sub com()

x = Val(l1.Caption)

Select Case t1

Case Is = 1: y = y + x

Case Is = 2: y = y - x

Case Is = 3: y = y * x

Case Is = 4: y = y / x

End Select

t1 = 0

t = 0

l1.Caption = "0"

End Sub

Private Sub Form_Load()

x = 0

y = 0

t = 0

t1 = 1

End Sub

Private Sub c0_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "0"

Else

l1.Caption = l1.Caption + "0"

End If

End Sub

Private Sub C1_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "1"

Else

l1.Caption = l1.Caption + "1"

End If

End Sub

Private Sub c10_Click(Index As Integer)

If t = 0 Then

l1.Caption = l1.Caption + "."

t = 1

End If

End Sub

Private Sub C2_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "2"

Else

l1.Caption = l1.Caption + "2"

End If

End Sub

Private Sub C3_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "3"

Else

l1.Caption = l1.Caption + "3"

End If

End Sub

Private Sub C4_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "4"

Else

l1.Caption = l1.Caption + "4"

End If

End Sub

Private Sub C5_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "5"

Else

l1.Caption = l1.Caption + "5"

End If

End Sub

Private Sub C6_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "6"

Else

l1.Caption = l1.Caption + "6"

End If

End Sub

Private Sub C7_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "7"

Else

l1.Caption = l1.Caption + "7"

End If

End Sub

Private Sub C8_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "8"

Else

l1.Caption = l1.Caption + "8"

End If

End Sub

Private Sub C9_Click(Index As Integer)

If l1.Caption = "0" Then

l1.Caption = "9"

Else

l1.Caption = l1.Caption + "9"

End If

End Sub

Private Sub z1_Click(Index As Integer)

com

t1 = 1

End Sub

Private Sub z2_Click(Index As Integer)

com

t1 = 2

End Sub

Private Sub z3_Click(Index As Integer)

com

t1 = 3

End Sub

Private Sub z4_Click(Index As Integer)

com

t1 = 4

End Sub

Private Sub z5_Click(Index As Integer)

tmp = Mid(l1.Caption, Len(l1.Caption), 1)

If tmp = "." Then

t = 0

End If

If Len(l1.Caption) = 1 Then

l1.Caption = "0"

Else

l1.Caption = Left(l1.Caption, Len(l1.Caption) - 1)

End If

End Sub

Private Sub z6_Click(Index As Integer)

l1.Caption = "0"

Form_Load

End Sub

Private Sub z7_Click(Index As Integer)

If (l1.Caption "0") Then

l1.Caption = "-" + l1.Caption

End If

End Sub

Private Sub z8_Click(Index As Integer)

com

l1.Caption = Str(y)

End Sub

擴展資料

語言缺點

Visual Basic 語言具有不支持繼承、無原生支持多線程、異常處理不完善等三項明顯缺點,使其有所局限性(此些缺點皆已在 vb .net 獲得改進)。

不支持繼承

VB 5.0 和 VB 6.0 都是基于對象的編程語言,但是不包含繼承特性。VB 中提供了特殊的類的功能,但是還是不能滿足程序員的需求。

無原生支持多線程

Visual Basic 對于多線程無原生支持,只能通過Windows API的調用實現(xiàn),且極其的不穩(wěn)定。因為在API創(chuàng)建的線程中,并沒有自動初始化運行時庫,導致部分的函數(shù)無法使用。一般的,在VB6等早期的VB開發(fā)環(huán)境下,使用API創(chuàng)建線程的目的是完成容易使程序假死的大量數(shù)據(jù)或者邏輯的計算。

異常處理不完善

Visual Basic 中內置異常處理,即使未寫異常處理代碼,一旦用戶出錯也會彈出一個明確寫出出錯原因對話框,接著程序終止。

Visual Basic 中可以使用 Err.Raise拋出異常。對系統(tǒng)及用戶拋出的異常的處理常用兩種模式:一是使用 On Error Resume Next 處理錯誤;另一種是使用 On Error Goto 將運行引入錯誤處理代碼。但相對 C++ 等語言而言,這樣的異常處理破壞了代碼的結構。

參考資料:百度百科-VB

如何用vb.net編寫一個簡單的計算器程序?。慷嘀x啊

你自己加窗體和空件吧

Private Sub a1_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X + Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a2_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X - Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a3_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X * Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a4_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X / Y

Text3.Text = s

Text3.Locked = True

End Sub

不會的叫我 在線談

當前題目:vb.net函數(shù)計算器 vb三角函數(shù)計算器代碼
分享地址:http://jinyejixie.com/article10/dodddgo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供響應式網(wǎng)站App開發(fā)、品牌網(wǎng)站建設動態(tài)網(wǎng)站、定制開發(fā)、標簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管
防城港市| 新泰市| 中宁县| 宁波市| 德令哈市| 仙居县| 且末县| 商水县| 吴旗县| 正蓝旗| 金乡县| 岳阳县| 岑巩县| 永靖县| 兴仁县| 汝城县| 修武县| 尚志市| 江孜县| 渭源县| 潮安县| 石台县| 阿拉善盟| 酒泉市| 资源县| 南皮县| 华池县| 庆元县| 丽江市| 肥乡县| 阳山县| 深水埗区| 温州市| 新密市| 新丰县| 安塞县| 三门县| 政和县| 广东省| 莒南县| 明溪县|