真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net計(jì)算器的代碼 vb實(shí)現(xiàn)計(jì)算器

用VB.NET編一個(gè)模擬袖珍計(jì)算器的完整程序

Public Class Form1

目前創(chuàng)新互聯(lián)公司已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、懷化網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

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.NET做一個(gè)簡單的計(jì)算器,當(dāng)然是做的越高級越好,不要生成的EXE。連程序一起發(fā)過來。采納追加500分!

計(jì)算機(jī)光要加減乘除的那種嗎?

先在窗口添加一個(gè)textbox文本框名字是textbox1,再添加一個(gè)標(biāo)簽,屬性text:(為一個(gè)空格)名字是label1,再加一個(gè)textbox文本框,名字是textbox2,加標(biāo)簽,名字是label2,屬性text:“=”(引號不算),在后面加一個(gè)文本框,名字為textbox3.下一行添加五個(gè)按鈕,名字分別是Button1(屬性text:加),Button2(屬性text:減).……最后一個(gè)是,清空,按鈕

雙擊Button1,輸入代碼:dim a,b,c as single(回車!)a=textbox1.text(!)b=textbox2.text(!)a+b=c(!),textbox3=c(!)

后面分別點(diǎn)擊不同的按鈕,把“+”改成“-”,“*”“/”行了

雙擊最后按鈕輸入textbox1=""(!)textbox2=""(!)textbox3=""就ok了,累死我了呵呵(!)表示回車昂

用VB做一個(gè)簡單的加減乘除的計(jì)算器,代碼是什么?

我們現(xiàn)在首先要做的就是拉出Label,準(zhǔn)備三個(gè)Label,把label1,label2,label3,這些改成第一個(gè)數(shù)、第二個(gè)數(shù)、結(jié)果。

我們現(xiàn)在要text也要拉出三個(gè),把了text里面text1、text2、text3全部刪掉。

我們現(xiàn)在要把command拉出四個(gè),把里面command1-4都給成+-*/

現(xiàn)在我們現(xiàn)在要雙擊+,我們開始進(jìn)行輸入代碼

在里面我們現(xiàn)在要:text3.text=val(text1.text)+val(text2.text)

我們要把這個(gè)(text3.text=val(text1.text)+val(text2.text))復(fù)制,把里面+號分別改成-*/

如圖,就像這樣就可以了,可以行徑了,如果你在哪個(gè)代碼里弄錯(cuò)了,你看一下還要哪些沒有拉出來,或者你哪個(gè)代碼輸錯(cuò)了。

感謝觀看。

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

Public C護(hù)激篙刻蕻灸戈熏恭抹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 .NET中調(diào)用記事本和計(jì)算器

這個(gè)啊,呵呵,應(yīng)該不難吧

先找到你要打開的應(yīng)用程序的文件

然后用一個(gè)調(diào)用代碼:

System.Diagnostics.Process.Start("C:\WINDOWS\system32\notepad.exe")

這是要開記事本的

System.Diagnostics.Process.Start("C:\WINDOWS\system32\calc.exe")

這是打開計(jì)算器的

應(yīng)該也可以把這兩個(gè)應(yīng)用程序復(fù)制到你的程序的默認(rèn)目錄下,就是BIN下吧!

呵呵,試試!!要給我加分哦!??!

用VB.NET編的計(jì)算器程序!

Public Class SimpleCalculator

Inherits System.Windows.Forms.Form

#Region " Windows 窗體設(shè)計(jì)器生成的代碼 "

Public Sub New()

MyBase.New()

'該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的。

InitializeComponent()

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

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 窗體設(shè)計(jì)器所必需的

Private components As System.ComponentModel.IContainer

'注意:以下過程是 Windows 窗體設(shè)計(jì)器所必需的

'可以使用 Windows 窗體設(shè)計(jì)器修改此過程。

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

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 = "結(jié)果:"

'

'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 = "計(jì)算"

'

'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 = "簡單計(jì)算器"

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 '把產(chǎn)生該事件的按鈕對象賦值給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屬性后連接一個(gè)空格、本按鈕的Text屬性值和一個(gè)空格

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ā)生錯(cuò)誤轉(zhuǎn)移到標(biāo)號“ErrorPro”指定的行去執(zhí)行錯(cuò)誤處理程序

On Error GoTo ErrorPro

Dim r As Decimal '保存計(jì)算結(jié)果的變量

Dim t As String = TextBox1.Text '用于保存文本框中的算術(shù)表達(dá)式

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

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

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

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

Dim s2 As String = t.Substring(space + 3) '通過取子串方法獲得第二個(gè)運(yùn)算數(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("輸入的運(yùn)算符有誤!")

Exit Sub

End Select

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

Exit Sub '退出過程

ErrorPro: '錯(cuò)誤處理程序塊

Select Case Err.Number

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

MsgBox("算術(shù)運(yùn)算溢出!", , "溢出提示")

TextBox1.Focus()

Exit Sub

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

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

Exit Sub

Case Else

'其它情況顯示錯(cuò)誤號和錯(cuò)誤原因

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

Exit Sub

End Select

End Sub

End Class


分享名稱:vb.net計(jì)算器的代碼 vb實(shí)現(xiàn)計(jì)算器
文章起源:http://weahome.cn/article/dodjsjg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部