| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1583 人关注过本帖
标题:小弟正在做一个带键盘输入的计算器难住了
只看楼主 加入收藏
homeway
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2005-12-13
收藏
 问题点数:0 回复次数:8 
小弟正在做一个带键盘输入的计算器难住了
哪位可以指点一下,谢谢.可以用小键盘来操纵计算器的运算.
搜索更多相关主题的帖子: 计算器 键盘 难住 输入 
2006-10-29 12:39
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 

Imports System.Math

Public Class pthouge
Inherits System.Windows.Forms.Form
Dim a As Double
Dim b As Double
Dim operator1 As Single
Dim operator2 As Single
Dim operator3 As Single
Dim operator4 As Single
Dim operator5 As Single
Private Sub ad1()
If (operator2 = 1 Or operator2 = 3) And operator5 = 1 Then
b = Val(TextBox1.Text)
TextBox1.Text = a
operator4 = 1
operator5 = 0
Call equalis()
End If
operator1 = 1
operator2 = 1
operator3 = 0
operator4 = 0
a = TextBox1.Text
End Sub
Private Sub small1()
If (operator2 = 1 Or operator2 = 3) And operator5 = 1 Then
b = Val(TextBox1.Text)
TextBox1.Text = a
operator4 = 1
operator5 = 0
Call equalis()
End If
operator1 = 2
operator2 = 1
operator3 = 0
operator4 = 0
a = TextBox1.Text
End Sub
Private Sub chen1()
If (operator2 = 1 Or operator2 = 3) And operator5 = 1 Then
b = Val(TextBox1.Text)
TextBox1.Text = a
operator4 = 1
operator5 = 0
Call equalis()
End If
operator1 = 3
operator2 = 1
operator3 = 0
operator4 = 0
a = TextBox1.Text
End Sub
Private Sub avg1()
If (operator2 = 1 Or operator2 = 3) And operator5 = 1 Then
b = Val(TextBox1.Text)
TextBox1.Text = a
operator4 = 0
operator5 = 0
Call equalis()
End If
operator1 = 4
operator2 = 1
operator3 = 0
operator4 = 0
a = TextBox1.Text
End Sub
Private Sub zero1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "0."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "0"
End If
End Sub
Private Sub one1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "1."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "1."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "1"
End If
End Sub
Private Sub two1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "2."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "2."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "2"
End If
End Sub
Private Sub three1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "3."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "3."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "3"
End If
End Sub
Private Sub four1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "4."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "4."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "4"
End If
End Sub
Private Sub five1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "5."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "5."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "5"
End If
End Sub
Private Sub six1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "6."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "6."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "6"
End If
End Sub
Private Sub seven1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "7."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "7."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "7"
End If
End Sub
Private Sub eight1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "8."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "8."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 Or operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "8"
End If
End Sub
Private Sub nine1()
If operator2 = 2 Then
Call cls()
TextBox1.Text = "0."
End If
If operator2 = 1 Then
TextBox1.Text = "0."
operator2 = 3
operator5 = 1
End If
If (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 And TextBox1.Text = "0." Then
TextBox1.Text = "9."
ElseIf (operator2 = 3 Or operator2 = 0) And InStr(Val(TextBox1.Text), ".") = 0 And operator3 = 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 1
TextBox1.Text = TextBox1.SelectedText
TextBox1.Text = TextBox1.Text & "9."
ElseIf (operator2 = 3 Or operator2 = 0) And (InStr(Val(TextBox1.Text), ".") <> 0 And operator3 = 1) Then
TextBox1.Text = TextBox1.Text & "9"
End If
End Sub
Private Sub cls()
a = 0
b = 0
operator1 = 0 '运算符
operator2 = 0 '判断有无运算符 0,无运算符 1,有运算符,2,运算符被用
operator3 = 0 '判断有无小数点
operator4 = 0 '=号的运算方法:0表示输入运算符后还未计算过,1表示运算过
operator5 = 0 '多次点击运算符的计算方法
TextBox1.Text = 0
End Sub
Private Sub equalis()
If operator4 = 1 Then
If operator1 = 1 Then
TextBox1.Text = Val(TextBox1.Text) + b
ElseIf operator1 = 2 Then
TextBox1.Text = Val(TextBox1.Text) - b
ElseIf operator1 = 3 Then
TextBox1.Text = Val(TextBox1.Text) * b
ElseIf operator1 = 4 Then
TextBox1.Text = Val(TextBox1.Text) / b
End If
If InStr(TextBox1.Text, ".") = 0 Then
TextBox1.Text = TextBox1.Text & "."
End If
End If

If operator4 = 0 Then
If operator1 = 0 Then
a = TextBox1.Text
End If

If operator1 = 1 Then
TextBox1.Text = Val(TextBox1.Text) + a
ElseIf operator1 = 2 Then
TextBox1.Text = a - Val(TextBox1.Text)
ElseIf operator1 = 3 Then
TextBox1.Text = Val(TextBox1.Text) * a
ElseIf operator1 = 4 Then
TextBox1.Text = a / Val(TextBox1.Text)
End If
If InStr(TextBox1.Text, ".") = 0 Then
TextBox1.Text = TextBox1.Text & "."
End If
End If
a = TextBox1.Text
End Sub


2006-11-02 03:00
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
Call cls()
Me.SetBounds(Me.Left, Me.Top, 298, 299)

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

End Sub

'窗体重写 dispose 以清理组件列表。
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 TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents one As System.Windows.Forms.Button
Friend WithEvents two As System.Windows.Forms.Button
Friend WithEvents three As System.Windows.Forms.Button
Friend WithEvents four As System.Windows.Forms.Button
Friend WithEvents five As System.Windows.Forms.Button
Friend WithEvents six As System.Windows.Forms.Button
Friend WithEvents seven As System.Windows.Forms.Button
Friend WithEvents eight As System.Windows.Forms.Button
Friend WithEvents nine As System.Windows.Forms.Button
Friend WithEvents sige As System.Windows.Forms.Button
Friend WithEvents avg As System.Windows.Forms.Button
Friend WithEvents chen As System.Windows.Forms.Button
Friend WithEvents small As System.Windows.Forms.Button
Friend WithEvents ad As System.Windows.Forms.Button
Friend WithEvents site As System.Windows.Forms.Button
Friend WithEvents hudren As System.Windows.Forms.Button
Friend WithEvents opsite As System.Windows.Forms.Button
Friend WithEvents BackSpace As System.Windows.Forms.Button
Friend WithEvents CE As System.Windows.Forms.Button
Friend WithEvents C As System.Windows.Forms.Button
Public WithEvents zero As System.Windows.Forms.Button
Friend WithEvents equal As System.Windows.Forms.Button
Friend WithEvents sqrt1 As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(pthouge))
Me.one = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.two = New System.Windows.Forms.Button
Me.three = New System.Windows.Forms.Button
Me.four = New System.Windows.Forms.Button
Me.five = New System.Windows.Forms.Button
Me.six = New System.Windows.Forms.Button
Me.seven = New System.Windows.Forms.Button
Me.eight = New System.Windows.Forms.Button
Me.nine = New System.Windows.Forms.Button
Me.zero = New System.Windows.Forms.Button
Me.sige = New System.Windows.Forms.Button
Me.site = New System.Windows.Forms.Button
Me.avg = New System.Windows.Forms.Button
Me.chen = New System.Windows.Forms.Button
Me.small = New System.Windows.Forms.Button
Me.ad = New System.Windows.Forms.Button
Me.sqrt1 = New System.Windows.Forms.Button
Me.hudren = New System.Windows.Forms.Button
Me.opsite = New System.Windows.Forms.Button
Me.equal = New System.Windows.Forms.Button
Me.BackSpace = New System.Windows.Forms.Button
Me.CE = New System.Windows.Forms.Button
Me.C = New System.Windows.Forms.Button
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Splitter1 = New System.Windows.Forms.Splitter
Me.SuspendLayout()
'
'one
'
Me.one.Location = New System.Drawing.Point(24, 184)
Me.one.Name = "one"
Me.one.Size = New System.Drawing.Size(48, 23)
Me.one.TabIndex = 12
Me.one.Text = "1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 48)
Me.TextBox1.MaxLength = 9
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(248, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = "0."
Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(96, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(100, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "简易计算器"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'two
'
Me.two.Location = New System.Drawing.Point(72, 184)
Me.two.Name = "two"
Me.two.Size = New System.Drawing.Size(48, 23)
Me.two.TabIndex = 3
Me.two.Text = "2"
'
'three
'
Me.three.ImageAlign = System.Drawing.ContentAlignment.BottomRight
Me.three.Location = New System.Drawing.Point(120, 184)
Me.three.Name = "three"
Me.three.Size = New System.Drawing.Size(48, 23)
Me.three.TabIndex = 4
Me.three.Text = "3"
'
'four
'
Me.four.Location = New System.Drawing.Point(24, 152)
Me.four.Name = "four"
Me.four.Size = New System.Drawing.Size(48, 22)
Me.four.TabIndex = 5
Me.four.Text = "4"
'
'five
'
Me.five.Location = New System.Drawing.Point(72, 151)
Me.five.Name = "five"
Me.five.Size = New System.Drawing.Size(48, 23)
Me.five.TabIndex = 6
Me.five.Text = "5"
'
'six
'
Me.six.Location = New System.Drawing.Point(120, 151)
Me.six.Name = "six"
Me.six.Size = New System.Drawing.Size(48, 23)
Me.six.TabIndex = 7
Me.six.Text = "6"
'
'seven
'
Me.seven.Location = New System.Drawing.Point(24, 120)
Me.seven.Name = "seven"
Me.seven.Size = New System.Drawing.Size(48, 23)
Me.seven.TabIndex = 8
Me.seven.Text = "7"
'
'eight
'
Me.eight.Location = New System.Drawing.Point(72, 120)
Me.eight.Name = "eight"
Me.eight.Size = New System.Drawing.Size(48, 23)
Me.eight.TabIndex = 9
Me.eight.Text = "8"
'
'nine
'
Me.nine.Location = New System.Drawing.Point(120, 120)
Me.nine.Name = "nine"
Me.nine.Size = New System.Drawing.Size(48, 23)
Me.nine.TabIndex = 10
Me.nine.Text = "9"
'
'zero
'
Me.zero.Location = New System.Drawing.Point(24, 216)
Me.zero.Name = "zero"
Me.zero.Size = New System.Drawing.Size(48, 23)
Me.zero.TabIndex = 11
Me.zero.TabStop = False
Me.zero.Text = "0"
'
'sige
'
Me.sige.Location = New System.Drawing.Point(72, 216)
Me.sige.Name = "sige"
Me.sige.Size = New System.Drawing.Size(48, 23)
Me.sige.TabIndex = 12
Me.sige.Text = "+/-"
'
'site
'
Me.site.Font = New System.Drawing.Font("宋体", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.site.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.site.Location = New System.Drawing.Point(120, 216)
Me.site.Name = "site"
Me.site.Size = New System.Drawing.Size(48, 23)
Me.site.TabIndex = 13
Me.site.Text = "."
'
'avg
'
Me.avg.Location = New System.Drawing.Point(168, 120)
Me.avg.Name = "avg"
Me.avg.Size = New System.Drawing.Size(48, 23)
Me.avg.TabIndex = 14
Me.avg.Text = "÷"
'
'chen
'
Me.chen.Location = New System.Drawing.Point(168, 151)
Me.chen.Name = "chen"
Me.chen.Size = New System.Drawing.Size(48, 23)
Me.chen.TabIndex = 15
Me.chen.Text = "*"
'
'small
'
Me.small.Location = New System.Drawing.Point(168, 184)
Me.small.Name = "small"
Me.small.Size = New System.Drawing.Size(48, 23)
Me.small.TabIndex = 16
Me.small.Text = "—"
'
'ad
'
Me.ad.Location = New System.Drawing.Point(168, 216)
Me.ad.Name = "ad"
Me.ad.Size = New System.Drawing.Size(48, 23)
Me.ad.TabIndex = 17
Me.ad.Text = "+"
'
'sqrt1
'
Me.sqrt1.Location = New System.Drawing.Point(216, 120)
Me.sqrt1.Name = "sqrt1"
Me.sqrt1.Size = New System.Drawing.Size(48, 23)
Me.sqrt1.TabIndex = 18
Me.sqrt1.Text = "sqrt"
'
'hudren
'
Me.hudren.Location = New System.Drawing.Point(216, 151)
Me.hudren.Name = "hudren"
Me.hudren.Size = New System.Drawing.Size(48, 23)
Me.hudren.TabIndex = 19
Me.hudren.Text = "%"
'
'opsite
'
Me.opsite.Location = New System.Drawing.Point(216, 184)
Me.opsite.Name = "opsite"
Me.opsite.Size = New System.Drawing.Size(48, 23)
Me.opsite.TabIndex = 20
Me.opsite.Text = "1/X"
'
'equal
'
Me.equal.Location = New System.Drawing.Point(216, 216)
Me.equal.Name = "equal"
Me.equal.Size = New System.Drawing.Size(48, 23)
Me.equal.TabIndex = 21
Me.equal.Text = "="
'
'BackSpace
'
Me.BackSpace.Location = New System.Drawing.Point(24, 88)
Me.BackSpace.Name = "BackSpace"
Me.BackSpace.Size = New System.Drawing.Size(80, 23)
Me.BackSpace.TabIndex = 22
Me.BackSpace.Text = "BackSpace"
'
'CE
'
Me.CE.Location = New System.Drawing.Point(104, 88)
Me.CE.Name = "CE"
Me.CE.Size = New System.Drawing.Size(80, 23)
Me.CE.TabIndex = 23
Me.CE.Text = "CE"
'
'C
'
Me.C.Location = New System.Drawing.Point(184, 88)
Me.C.Name = "C"
Me.C.Size = New System.Drawing.Size(80, 23)
Me.C.TabIndex = 24
Me.C.Text = "C"
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(248, 8)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(24, 24)
Me.PictureBox1.TabIndex = 25
Me.PictureBox1.TabStop = False
'
'PictureBox2
'
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.Location = New System.Drawing.Point(312, 24)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(100, 104)
Me.PictureBox2.TabIndex = 26
Me.PictureBox2.TabStop = False
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox2.Location = New System.Drawing.Point(312, 152)
Me.TextBox2.Multiline = True
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(112, 88)
Me.TextBox2.TabIndex = 27
Me.TextBox2.Text = "s为退格键 c为清除 其余的直接用键盘输入"
'
'Splitter1
'
Me.Splitter1.Location = New System.Drawing.Point(0, 0)
Me.Splitter1.Name = "Splitter1"
Me.Splitter1.Size = New System.Drawing.Size(3, 270)
Me.Splitter1.TabIndex = 28
Me.Splitter1.TabStop = False
'
'pthouge
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.Color.Gainsboro
Me.ClientSize = New System.Drawing.Size(432, 270)
Me.Controls.Add(Me.Splitter1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.C)
Me.Controls.Add(Me.CE)
Me.Controls.Add(Me.BackSpace)
Me.Controls.Add(Me.equal)
Me.Controls.Add(Me.opsite)
Me.Controls.Add(Me.hudren)
Me.Controls.Add(Me.sqrt1)
Me.Controls.Add(Me.ad)
Me.Controls.Add(Me.small)
Me.Controls.Add(Me.chen)
Me.Controls.Add(Me.avg)
Me.Controls.Add(Me.site)
Me.Controls.Add(Me.sige)
Me.Controls.Add(Me.zero)
Me.Controls.Add(Me.nine)
Me.Controls.Add(Me.eight)
Me.Controls.Add(Me.seven)
Me.Controls.Add(Me.six)
Me.Controls.Add(Me.five)
Me.Controls.Add(Me.four)
Me.Controls.Add(Me.three)
Me.Controls.Add(Me.two)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.one)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.KeyPreview = True
Me.Name = "pthouge"
Me.Text = "pthouge"
Me.ResumeLayout(False)

End Sub

#End Region


2006-11-02 03:02
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

Private Sub ad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ad.Click
Call ad1()
Label1.Focus()
End Sub

Private Sub small_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles small.Click
Call small1()
Label1.Focus()
End Sub

Private Sub chen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chen.Click
Call chen1()
Label1.Focus()
End Sub

Private Sub avg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles avg.Click
Call avg1()
Label1.Focus()
End Sub

Private Sub equal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles equal.Click
If operator4 = 0 And operator1 <> 0 Then
b = TextBox1.Text
End If
Call equalis()
operator2 = 2
operator4 = 1
operator5 = 0
Label1.Focus()
End Sub

Private Sub C_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C.Click
Call cls()
End Sub

Private Sub CE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CE.Click
Call cls()
End Sub

Private Sub BackSpace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackSpace.Click
If TextBox1.TextLength <> 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 2
TextBox1.Text = TextBox1.SelectedText & "."
End If
If TextBox1.TextLength = 1 Then
TextBox1.Text = "0."
End If
End Sub

Private Sub zero_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles zero.Click
Call zero1()
Label1.Focus()
End Sub

Private Sub one_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles one.Click
Call one1()
Label1.Focus()
End Sub

Private Sub two_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles two.Click
Call two1()
Label1.Focus()
End Sub

Private Sub three_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles three.Click
Call three1()
Label1.Focus()
End Sub

Private Sub four_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles four.Click
Call four1()
Label1.Focus()
End Sub

Private Sub five_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles five.Click
Call five1()
Label1.Focus()
End Sub

Private Sub six_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles six.Click
Call six1()
Label1.Focus()
End Sub

Private Sub seven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seven.Click
Call seven1()
Label1.Focus()
End Sub

Private Sub eight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles eight.Click
Call eight1()
Label1.Focus()
End Sub

Private Sub nine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nine.Click
Call nine1()
Label1.Focus()
End Sub

Private Sub sqrt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sqrt1.Click
TextBox1.Text = Sqrt(TextBox1.Text)
If InStr(TextBox1.Text, ".") = 0 Then
TextBox1.Text = TextBox1.Text & "."
End If
Label1.Focus()
End Sub

Private Sub site_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles site.Click
If InStr(Val(TextBox1.Text), ".") = 0 Then
operator3 = 1
Label1.Focus()
End If
End Sub

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If e.KeyChar = Chr(48) Then
Call zero1()

ElseIf e.KeyChar = Chr(49) Then
Call one1()
ElseIf e.KeyChar = Chr(50) Then
Call two1()
ElseIf e.KeyChar = Chr(51) Then
Call three1()
ElseIf e.KeyChar = Chr(52) Then
Call four1()
ElseIf e.KeyChar = Chr(53) Then
Call five1()
ElseIf e.KeyChar = Chr(54) Then
Call six1()
ElseIf e.KeyChar = Chr(55) Then
Call seven1()
ElseIf e.KeyChar = Chr(56) Then
Call eight1()
ElseIf e.KeyChar = Chr(57) Then
Call nine1()
ElseIf e.KeyChar = Chr(46) Then
operator3 = 1
ElseIf e.KeyChar = Chr(43) Then
Call ad1()
ElseIf e.KeyChar = Chr(45) Then
Call small1()
ElseIf e.KeyChar = Chr(42) Then
Call chen1()
ElseIf e.KeyChar = Chr(47) Then
Call avg1()
ElseIf e.KeyChar = Chr(61) Or e.KeyChar = Chr(13) Then
If operator4 = 0 And operator1 <> 0 Then
b = TextBox1.Text
End If
Call equalis()
operator2 = 2
operator4 = 1
operator5 = 0
ElseIf e.KeyChar = Chr(27) Or e.KeyChar = Chr(67) Or e.KeyChar = Chr(99) Then
Call cls()
ElseIf e.KeyChar = Chr(83) Or e.KeyChar = Chr(115) Then
If TextBox1.TextLength <> 0 Then
TextBox1.SelectionLength = TextBox1.TextLength - 2
TextBox1.Text = TextBox1.SelectedText & "."
End If
If TextBox1.TextLength = 1 Then
TextBox1.Text = "0."
End If
End If
End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Me.SetBounds(Me.Left, Me.Top, 440, 304)
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Me.SetBounds(Me.Left, Me.Top, 298, 299)
End Sub
End Class


2006-11-02 03:02
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 
我也刚开始学vb不什么会,以上是用VB.net 写的,挺烦琐的,不知道是不是你所要求的


2006-11-02 03:06
oO冰河Oo
Rank: 1
等 级:新手上路
帖 子:109
专家分:0
注 册:2006-10-29
收藏
得分:0 

这是你写的啊
那么长啊
受不了
晕了


苍天问我 :你知道我是一个什么样的人吗? 我说   :你和我一样的
2006-11-03 19:14
贝_贝
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-10-20
收藏
得分:0 
偶也晕了。
2006-11-04 15:37
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
是个强人啊,看到都晕了.

飘过~~
2006-11-04 22:43
xinsheng
Rank: 2
等 级:论坛游民
帖 子:43
专家分:15
注 册:2006-6-28
收藏
得分:0 

这么长,这只能说你的水平一般,以前我看过一个没有你的复杂...
可惜今天偶没有找到...
用键盘操作可以它们都放到窗体的Keyup 或Keypress 的事件里...记得要用e 个参数


2006-11-13 18:26
快速回复:小弟正在做一个带键盘输入的计算器难住了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019633 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved