值不能這樣加的吧,應(yīng)該要把它寫進(jìn)cint()的函數(shù)里,就是cint(name1.value)+cint(name2.value )
創(chuàng)新互聯(lián)建站2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元任城做網(wǎng)站,已為上家服務(wù),為任城各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792
創(chuàng)建一個(gè)工程
添加一個(gè)按扭
雙擊按扭
輸入如下
msgbox ("Hello World!")
按F5
所有的可視開發(fā)工具基本都是這個(gè)流程,關(guān)鍵還是要學(xué)相關(guān)語言標(biāo)準(zhǔn)。
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 = "簡(jiǎn)單計(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)生該事件的按鈕對(duì)象賦值給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)號(hà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ò)誤號(hào)為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ò)誤號(hào)
MsgBox("算術(shù)運(yùn)算溢出!", , "溢出提示")
TextBox1.Focus()
Exit Sub
Case 5 ' Substring過程的參數(shù)不符合要求的錯(cuò)誤號(hào)
MsgBox("必須輸入運(yùn)算符和第二個(gè)運(yùn)算數(shù)!", , "運(yùn)算數(shù)少")
Exit Sub
Case Else
'其它情況顯示錯(cuò)誤號(hào)和錯(cuò)誤原因
MsgBox("錯(cuò)誤號(hào)為" Err.Number Chr(10) Chr(13) "錯(cuò)誤原因:" Err.Description)
Exit Sub
End Select
End Sub
End Class
'這個(gè)很簡(jiǎn)單的了,你用記事本把這段代碼復(fù)制過去,然后另存為.frm就可以了
'然后用vb打開。看看效果。
'以下保存為 任務(wù)名稱.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "計(jì)算機(jī)"
ClientHeight = 4230
ClientLeft = 60
ClientTop = 750
ClientWidth = 3165
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4230
ScaleWidth = 3165
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 3495
Left = 120
TabIndex = 1
Top = 600
Width = 2895
Begin VB.CommandButton cmdResult
Caption = "="
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 20
Top = 3000
Width = 1695
End
Begin VB.CommandButton cmdOff
Caption = "OFF"
Height = 375
Left = 1560
TabIndex = 19
Top = 240
Width = 495
End
Begin VB.CommandButton cmdCE
Caption = "CE"
Height = 375
Left = 2280
TabIndex = 18
Top = 240
Width = 495
End
Begin VB.CommandButton cmdchu
Caption = "/"
Height = 375
Left = 2280
TabIndex = 17
Top = 2520
Width = 495
End
Begin VB.CommandButton cmdjia
Caption = "+"
Height = 375
Left = 2280
TabIndex = 16
Top = 720
Width = 495
End
Begin VB.CommandButton cmd0
Caption = "0"
Height = 375
Left = 840
TabIndex = 15
Top = 2520
Width = 495
End
Begin VB.CommandButton cmd6
Caption = "6"
Height = 375
Left = 1560
TabIndex = 14
Top = 1320
Width = 495
End
Begin VB.CommandButton cmd8
Caption = "8"
Height = 375
Left = 840
TabIndex = 13
Top = 720
Width = 495
End
Begin VB.CommandButton cmd4
Caption = "4"
Height = 375
Left = 120
TabIndex = 12
Top = 1320
Width = 495
End
Begin VB.CommandButton cmd9
Caption = "9"
Height = 375
Left = 1560
TabIndex = 11
Top = 720
Width = 495
End
Begin VB.CommandButton cmd2
Caption = "2"
Height = 375
Left = 840
TabIndex = 10
Top = 1920
Width = 495
End
Begin VB.CommandButton cmdjian
Caption = "-"
Height = 375
Left = 2280
TabIndex = 9
Top = 1320
Width = 495
End
Begin VB.CommandButton cmdPoint
Caption = "."
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 8
Top = 2520
Width = 495
End
Begin VB.CommandButton cmdcheng
Caption = "*"
Height = 375
Left = 2280
TabIndex = 7
Top = 1920
Width = 495
End
Begin VB.CommandButton cmd5
Caption = "5"
Height = 375
Left = 840
TabIndex = 6
Top = 1320
Width = 495
End
Begin VB.CommandButton cmd3
Caption = "3"
Height = 375
Left = 1560
TabIndex = 5
Top = 1905
Width = 495
End
Begin VB.CommandButton cmd1
Caption = "1"
Height = 375
Left = 120
TabIndex = 4
Top = 1920
Width = 495
End
Begin VB.CommandButton cmd7
Caption = "7"
Height = 375
Left = 120
TabIndex = 3
Top = 720
Width = 495
End
Begin VB.CommandButton cmdChange
Caption = "+/-"
Height = 375
Left = 120
TabIndex = 2
Top = 2520
Width = 495
End
End
Begin VB.TextBox txt
Alignment = 1 'Right Justify
Enabled = 0 'False
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
Locked = -1 'True
TabIndex = 0
Top = 120
Width = 2895
End
Begin VB.Menu meuFile
Caption = "文件(F)"
Begin VB.Menu meuExit
Caption = "退出(X)"
Shortcut = ^X
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim XiaoShu As Boolean
'在窗體變量中聲明一個(gè)布爾值來判斷是否按下了小數(shù)點(diǎn)鍵,防止txt中出現(xiàn)多個(gè)小數(shù)。如果已經(jīng)輸入了小數(shù)點(diǎn)則Xiaoshu為True,否則為False
Dim FuHao As Byte
'聲明一個(gè)Byte來記錄我們按下了什么符號(hào),1為"+",2為"-",3為"*",4為"/"
Dim FirstNumber As Double
'聲明一個(gè)變量來記錄操作數(shù)的第一個(gè)數(shù),如A+B,那么FirstNumber來記下A的值。
Dim DengHao As Boolean
'聲明一個(gè)變量來記錄是否按下了=號(hào),如果按下了則為True
Private Sub cmd0_Click()
If txt.Text "" Then txt.Text = txt.Text + "0" '防止多個(gè)0在文本中出現(xiàn)
End Sub
Private Sub cmd1_Click() '按下1時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "1"
Else
txt.Text = "1" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd2_Click() '按下2時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "2"
Else
txt.Text = "2" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd3_click() '按下3時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "3"
Else
txt.Text = "3" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd4_Click() '按下4時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "4"
Else
txt.Text = "4" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd5_Click() '按下5時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "5"
Else
txt.Text = "5" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd6_Click() '按下6時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "6"
Else
txt.Text = "6" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd7_Click() '按下7時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "7"
Else
txt.Text = "7" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd8_Click() '按下8時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "8"
Else
txt.Text = "8" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmd9_Click() '按下9時(shí)
If Not DengHao Then '沒按下等號(hào)
txt.Text = txt.Text + "9"
Else
txt.Text = "9" '按下了等號(hào)
DengHao = False
End If
End Sub
Private Sub cmdCE_Click()
txt.Text = ""
XiaoShu = False
End Sub
Private Sub cmdChange_Click()
If (Sgn(Val(txt.Text))) = 1 Then txt.Text = "-" + txt.Text: Exit Sub '用Sgn來判斷txt文本框內(nèi)的值的符號(hào)。大于0的話就在前面加上"-"
If (Sgn(Val(txt.Text))) = -1 Then txt.Text = Abs(Val(txt.Text)) 'txt文本框的文本為大于0的數(shù)txt前面的"-"去掉。
End Sub
Private Sub cmdcheng_Click()
FirstNumber = Val(txt.Text)
FuHao = 3
txt.Text = ""
XiaoShu = False
End Sub
Private Sub cmdchu_Click()
FirstNumber = Val(txt.Text)
FuHao = 4
txt.Text = ""
XiaoShu = False
End Sub
Private Sub cmdjia_Click()
FirstNumber = Val(txt.Text)
FuHao = 1
txt.Text = ""
XiaoShu = False
End Sub
Private Sub cmdjian_Click()
FirstNumber = Val(txt.Text)
FuHao = 2
txt.Text = ""
XiaoShu = False
End Sub
Private Sub cmdOff_Click()
End
End Sub
Private Sub cmdPoint_Click()
If txt.Text = "" Then txt.Text = "0"
If Not XiaoShu Then '當(dāng)我們以前沒有按下小數(shù)點(diǎn)鍵時(shí)在txt中加上小數(shù)點(diǎn)
txt.Text = txt.Text + "."
XiaoShu = True
End If
End Sub
Private Sub cmdResult_Click()
If FuHao = 1 Then '按下了+號(hào)
txt.Text = FirstNumber + Val(txt.Text)
End If
If FuHao = 2 Then '按下了-號(hào)
txt.Text = FirstNumber - Val(txt.Text)
End If
If FuHao = 3 Then '按下了*號(hào)
txt.Text = FirstNumber * Val(txt.Text)
End If
If FuHao = 4 Then '按下了、號(hào)
txt.Text = FirstNumber / Val(txt.Text)
End If
DengHao = True '記錄下按了=號(hào)
XiaoShu = False
End Sub
Private Sub meuExit_Click()
End
End Sub
在窗體上畫三個(gè)文本框,五個(gè)按鍵
按健代碼分別為
加法按鍵里寫:text3= val(text1) + val(text2)
減法按鍵里寫:text3= val(text1) - val(text2)
乘法按鍵里寫:text3= val(text1) * val(text2)
除法按鍵里寫:text3= val(text1) / val(text2)
這樣就可以。
網(wǎng)站題目:vb.net做一個(gè)計(jì)算機(jī) VBNET程序設(shè)計(jì)
URL鏈接:http://vcdvsql.cn/article8/dooddop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、虛擬主機(jī)、企業(yè)建站、定制網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)