VB.net上的清除按钮问题

时间:2015-05-22 10:06:10

标签: vb.net

我正在尝试使用Vb.net制作计算器并面临两个问题。

1)我已经完成编码一切正常工作但是当我点击清除按钮然后+, - ,/,= STOPS工作......

2)当我添加或减去它时,等号按钮也无法正常工作

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    Try
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
    Finally
        MyBase.Dispose(disposing)
    End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.  
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
    Me.btnclear = New System.Windows.Forms.Button()
    Me.btnseven = New System.Windows.Forms.Button()
    Me.btnfour = New System.Windows.Forms.Button()
    Me.btnone = New System.Windows.Forms.Button()
    Me.Btntwo = New System.Windows.Forms.Button()
    Me.Btnthree = New System.Windows.Forms.Button()
    Me.Buttonmulty = New System.Windows.Forms.Button()
    Me.lblDisplay = New System.Windows.Forms.Label()
    Me.btnzero = New System.Windows.Forms.Button()
    Me.btn5 = New System.Windows.Forms.Button()
    Me.Buttonsix = New System.Windows.Forms.Button()
    Me.Buttoneight = New System.Windows.Forms.Button()
    Me.ButtonNine = New System.Windows.Forms.Button()
    Me.Buttonbot = New System.Windows.Forms.Button()
    Me.ButtonMnus = New System.Windows.Forms.Button()
    Me.Buttonplus = New System.Windows.Forms.Button()
    Me.Buttonmlt = New System.Windows.Forms.Button()
    Me.equalbutton = New System.Windows.Forms.Button()
    Me.Button3 = New System.Windows.Forms.Button()
    Me.minusandadd = New System.Windows.Forms.Button()
    Me.Button1 = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'btnclear
    '
    Me.btnclear.BackColor = System.Drawing.Color.Red
    Me.btnclear.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnclear.Location = New System.Drawing.Point(211, 270)
    Me.btnclear.Name = "btnclear"
    Me.btnclear.Size = New System.Drawing.Size(55, 41)
    Me.btnclear.TabIndex = 0
    Me.btnclear.Text = "C"
    Me.btnclear.UseVisualStyleBackColor = False
    '
    'btnseven
    '
    Me.btnseven.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnseven.Location = New System.Drawing.Point(17, 175)
    Me.btnseven.Name = "btnseven"
    Me.btnseven.Size = New System.Drawing.Size(55, 41)
    Me.btnseven.TabIndex = 0
    Me.btnseven.Text = "7"
    Me.btnseven.UseVisualStyleBackColor = True
    '
    'btnfour
    '
    Me.btnfour.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnfour.Location = New System.Drawing.Point(17, 128)
    Me.btnfour.Name = "btnfour"
    Me.btnfour.Size = New System.Drawing.Size(55, 41)
    Me.btnfour.TabIndex = 0
    Me.btnfour.Text = "4"
    Me.btnfour.UseVisualStyleBackColor = True
    '
    'btnone
    '
    Me.btnone.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnone.Location = New System.Drawing.Point(17, 81)
    Me.btnone.Name = "btnone"
    Me.btnone.Size = New System.Drawing.Size(55, 41)
    Me.btnone.TabIndex = 0
    Me.btnone.Text = "1"
    Me.btnone.UseVisualStyleBackColor = True
    '
    'Btntwo
    '
    Me.Btntwo.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Btntwo.Location = New System.Drawing.Point(78, 81)
    Me.Btntwo.Name = "Btntwo"
    Me.Btntwo.Size = New System.Drawing.Size(55, 41)
    Me.Btntwo.TabIndex = 0
    Me.Btntwo.Text = "2"
    Me.Btntwo.UseVisualStyleBackColor = True
    '
    'Btnthree
    '
    Me.Btnthree.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Btnthree.Location = New System.Drawing.Point(139, 81)
    Me.Btnthree.Name = "Btnthree"
    Me.Btnthree.Size = New System.Drawing.Size(55, 41)
    Me.Btnthree.TabIndex = 0
    Me.Btnthree.Text = "3"
    Me.Btnthree.UseVisualStyleBackColor = True
    '
    'Buttonmulty
    '
    Me.Buttonmulty.Font = New System.Drawing.Font("Microsoft Sans Serif", 16.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttonmulty.Location = New System.Drawing.Point(211, 81)
    Me.Buttonmulty.Name = "Buttonmulty"
    Me.Buttonmulty.Size = New System.Drawing.Size(55, 41)
    Me.Buttonmulty.TabIndex = 0
    Me.Buttonmulty.Text = "/"
    Me.Buttonmulty.UseVisualStyleBackColor = True
    '
    'lblDisplay
    '
    Me.lblDisplay.BackColor = System.Drawing.Color.White
    Me.lblDisplay.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.lblDisplay.Location = New System.Drawing.Point(17, 20)
    Me.lblDisplay.Name = "lblDisplay"
    Me.lblDisplay.Size = New System.Drawing.Size(249, 43)
    Me.lblDisplay.TabIndex = 1
    Me.lblDisplay.Text = "0"
    Me.lblDisplay.TextAlign = System.Drawing.ContentAlignment.MiddleRight
    '
    'btnzero
    '
    Me.btnzero.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnzero.Location = New System.Drawing.Point(17, 222)
    Me.btnzero.Name = "btnzero"
    Me.btnzero.Size = New System.Drawing.Size(55, 41)
    Me.btnzero.TabIndex = 2
    Me.btnzero.Text = "0"
    Me.btnzero.UseVisualStyleBackColor = True
    '
    'btn5
    '
    Me.btn5.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btn5.Location = New System.Drawing.Point(78, 128)
    Me.btn5.Name = "btn5"
    Me.btn5.Size = New System.Drawing.Size(55, 41)
    Me.btn5.TabIndex = 0
    Me.btn5.Text = "5"
    Me.btn5.UseVisualStyleBackColor = True
    '
    'Buttonsix
    '
    Me.Buttonsix.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttonsix.Location = New System.Drawing.Point(139, 128)
    Me.Buttonsix.Name = "Buttonsix"
    Me.Buttonsix.Size = New System.Drawing.Size(55, 41)
    Me.Buttonsix.TabIndex = 0
    Me.Buttonsix.Text = "6"
    Me.Buttonsix.UseVisualStyleBackColor = True
    '
    'Buttoneight
    '
    Me.Buttoneight.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttoneight.Location = New System.Drawing.Point(78, 175)
    Me.Buttoneight.Name = "Buttoneight"
    Me.Buttoneight.Size = New System.Drawing.Size(55, 41)
    Me.Buttoneight.TabIndex = 0
    Me.Buttoneight.Text = "8"
    Me.Buttoneight.UseVisualStyleBackColor = True
    '
    'ButtonNine
    '
    Me.ButtonNine.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.ButtonNine.Location = New System.Drawing.Point(139, 175)
    Me.ButtonNine.Name = "ButtonNine"
    Me.ButtonNine.Size = New System.Drawing.Size(55, 41)
    Me.ButtonNine.TabIndex = 0
    Me.ButtonNine.Text = "9"
    Me.ButtonNine.UseVisualStyleBackColor = True
    '
    'Buttonbot
    '
    Me.Buttonbot.Font = New System.Drawing.Font("Microsoft Sans Serif", 25.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttonbot.Location = New System.Drawing.Point(78, 222)
    Me.Buttonbot.Name = "Buttonbot"
    Me.Buttonbot.Size = New System.Drawing.Size(55, 41)
    Me.Buttonbot.TabIndex = 0
    Me.Buttonbot.Text = "."
    Me.Buttonbot.UseVisualStyleBackColor = True
    '
    'ButtonMnus
    '
    Me.ButtonMnus.Font = New System.Drawing.Font("Microsoft Sans Serif", 25.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.ButtonMnus.Location = New System.Drawing.Point(139, 222)
    Me.ButtonMnus.Name = "ButtonMnus"
    Me.ButtonMnus.Size = New System.Drawing.Size(55, 41)
    Me.ButtonMnus.TabIndex = 0
    Me.ButtonMnus.Text = "-"
    Me.ButtonMnus.UseVisualStyleBackColor = True
    '
    'Buttonplus
    '
    Me.Buttonplus.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttonplus.Location = New System.Drawing.Point(211, 128)
    Me.Buttonplus.Name = "Buttonplus"
    Me.Buttonplus.Size = New System.Drawing.Size(55, 41)
    Me.Buttonplus.TabIndex = 0
    Me.Buttonplus.Text = "+"
    Me.Buttonplus.UseVisualStyleBackColor = True
    '
    'Buttonmlt
    '
    Me.Buttonmlt.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Buttonmlt.Location = New System.Drawing.Point(211, 175)
    Me.Buttonmlt.Name = "Buttonmlt"
    Me.Buttonmlt.Size = New System.Drawing.Size(55, 41)
    Me.Buttonmlt.TabIndex = 0
    Me.Buttonmlt.Text = "*"
    Me.Buttonmlt.UseVisualStyleBackColor = True
    '
    'equalbutton
    '
    Me.equalbutton.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.equalbutton.Location = New System.Drawing.Point(211, 223)
    Me.equalbutton.Name = "equalbutton"
    Me.equalbutton.RightToLeft = System.Windows.Forms.RightToLeft.Yes
    Me.equalbutton.Size = New System.Drawing.Size(55, 41)
    Me.equalbutton.TabIndex = 3
    Me.equalbutton.Text = "="
    Me.equalbutton.UseVisualStyleBackColor = True
    '
    'Button3
    '
    Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Button3.Location = New System.Drawing.Point(17, 269)
    Me.Button3.Name = "Button3"
    Me.Button3.Size = New System.Drawing.Size(55, 41)
    Me.Button3.TabIndex = 5
    Me.Button3.Text = "00"
    Me.Button3.UseVisualStyleBackColor = True
    '
    'minusandadd
    '
    Me.minusandadd.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.minusandadd.Location = New System.Drawing.Point(139, 269)
    Me.minusandadd.Name = "minusandadd"
    Me.minusandadd.Size = New System.Drawing.Size(55, 41)
    Me.minusandadd.TabIndex = 0
    Me.minusandadd.Text = "-/+"
    Me.minusandadd.UseVisualStyleBackColor = True
    '
    'Button1
    '
    Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Button1.Location = New System.Drawing.Point(78, 269)
    Me.Button1.Name = "Button1"
    Me.Button1.Size = New System.Drawing.Size(55, 41)
    Me.Button1.TabIndex = 6
    Me.Button1.Text = "←"
    Me.Button1.UseVisualStyleBackColor = True
    '
    'calcuTESTForm1
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(277, 323)
    Me.Controls.Add(Me.Button1)
    Me.Controls.Add(Me.Button3)
    Me.Controls.Add(Me.equalbutton)
    Me.Controls.Add(Me.btnzero)
    Me.Controls.Add(Me.lblDisplay)
    Me.Controls.Add(Me.Buttonmulty)
    Me.Controls.Add(Me.btnclear)
    Me.Controls.Add(Me.minusandadd)
    Me.Controls.Add(Me.ButtonMnus)
    Me.Controls.Add(Me.Buttonbot)
    Me.Controls.Add(Me.Buttonmlt)
    Me.Controls.Add(Me.ButtonNine)
    Me.Controls.Add(Me.Buttoneight)
    Me.Controls.Add(Me.Buttonplus)
    Me.Controls.Add(Me.Buttonsix)
    Me.Controls.Add(Me.btn5)
    Me.Controls.Add(Me.Btnthree)
    Me.Controls.Add(Me.Btntwo)
    Me.Controls.Add(Me.btnone)
    Me.Controls.Add(Me.btnfour)
    Me.Controls.Add(Me.btnseven)
    Me.MaximizeBox = False
    Me.Name = "calcuTESTForm1"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "kevulator"
    Me.ResumeLayout(False)

End Sub
Friend WithEvents btnclear As System.Windows.Forms.Button
Friend WithEvents btnseven As System.Windows.Forms.Button
Friend WithEvents btnfour As System.Windows.Forms.Button
Friend WithEvents btnone As System.Windows.Forms.Button
Friend WithEvents Btntwo As System.Windows.Forms.Button
Friend WithEvents Btnthree As System.Windows.Forms.Button
Friend WithEvents Buttonmulty As System.Windows.Forms.Button
Friend WithEvents lblDisplay As System.Windows.Forms.Label
Friend WithEvents btnzero As System.Windows.Forms.Button
Friend WithEvents btn5 As System.Windows.Forms.Button
Friend WithEvents Buttonsix As System.Windows.Forms.Button
Friend WithEvents Buttoneight As System.Windows.Forms.Button
Friend WithEvents ButtonNine As System.Windows.Forms.Button
Friend WithEvents Buttonbot As System.Windows.Forms.Button
Friend WithEvents ButtonMnus As System.Windows.Forms.Button
Friend WithEvents Buttonplus As System.Windows.Forms.Button
Friend WithEvents Buttonmlt As System.Windows.Forms.Button
Friend WithEvents equalbutton As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents minusandadd As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button

_ Partial类calcuTESTForm1     继承System.Windows.Forms.Form

{{1}}

结束班

1 个答案:

答案 0 :(得分:0)

乍一看,看起来其中一个错误就在这个子

The type or namespace name 'FormUrlEncodedContent' could not be found (are you missing a using directive or an assembly reference?)

如果btn4不是清除按钮的名称,则子类似

        Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btn4.Click
        lblDisplay.Text = ""
        lblDisplay.Text = 0
        isDotExixtsbool = True
        End Sub

如果您可以提供设计师的代码(可能是CalcuTESTform1.Designer.vb),那么我们可以为您提供更多帮助。