vb+.net数组计算器 vb设计一个简单的数字计算器

VB.NET怎么编模拟袖珍计算器的完整程序?

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

成都创新互联是一家专注于网站设计、做网站与策划设计,乾安网站建设哪家好?成都创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:乾安等地区。乾安做网站价格咨询:028-86922220

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编写一个简单的计算器程序啊?多谢啊

你自己加窗体和空件吧

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控件数组制作一个只有加减乘除的简易计算器

以下是一个简单的+-*/的计算器代码,按钮采用数组,text2不可见。详情也可在我的百度空间里查看“vb6 比较简单的计算器代码”下载源文件和说明。

Function Eval(ByVal Expressions As String) As String '文本运算vbs

Dim Mssc As Object

Set Mssc = CreateObject("MSScriptControl.ScriptControl")

Mssc.Language = "vbscript"

On Error GoTo EvalErr

Eval = Mssc.Eval(Expressions)

Exit Function

EvalErr:

Exit Function

End Function

Private Sub Command1_Click(Index As Integer)

Dim i As Long, j As Long

For i = 0 To 10 '数字输出0-9和小数点,输入按钮的Caption值

If Index = i Then

Text2 = Text2 Command1(i).Caption

Text1 = Format$(Eval(Text2), "0.########") '格式化小于1大于-1的数,下同

End If

Next i

For j = 11 To 14 '运算符号输出+-*/,输入按钮的Caption值

If Index = j Then

Text1 = Format$(Eval(Text2), "0.########")

Text2 = Text1 Command1(j).Caption

End If

Next j

End Sub

如何用vb中控件数组做一个简易计算器?

我给你做个简单的 吧 只做 + - * \ 创建工程后 2个textbox 文本框控件 4个command 按纽控件 1个lalbel 标签控件 代码实现如下:

dim a as integer , b as integer, sum as integer

a=text1.text

b=text2.text

Private Sub command1_Click()

sum=a+b

lalbel1.caption=sum

end sub

Private Sub command2_Click()

sum=a-b

lalbel1.caption=sum

end sub

Private Sub command3_Click()

sum=a*b

lalbel1.caption=sum

end sub

Private Sub command4_Click()

sum=a\b

lalbel1.caption=sum

end sub

代码就这样 , 按照你的要求写的 希望给我加分哦


网站标题:vb+.net数组计算器 vb设计一个简单的数字计算器
文章来源:http://cdiso.cn/article/dogisdc.html

其他资讯