vb.net计算器 如何用vb编写计算器

有关vb.net制作计算器的问题判断吧,如果点击+按钮,则一个全局变量为1,-按钮,则全局变量为2.以此类推 , 然后if或case判断哪个数,如果为1,就两个数相加 。
VB.NET怎么编模拟袖珍计算器的完整程序?Public C护激篙刻蕻灸戈熏恭抹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编程序】做一个记事本和计算器上次vb.net计算器你说是vb6.0 啊
怎么又变成vb.netvb.net计算器了
用VB.net编计算器的问题1、把文本框的属性TextAlign设置为Right,数字就可以在文本框的右边显示了;
2、FormBordetStyle的值设置为FixedSingle窗口的大小就不可调整了 。
3、给文本框添加先面的方法,就可以禁止文本框输入字符 。
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim tpu
If Not IsNumericRegex(TextBox1.Text) Then
tpu = MsgBox("此框中只允许输入数字!", , "错误")
If Len(TextBox1.Text)0 Then
TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
Else
TextBox1.Text = 0
End If
TextBox1.Focus()
TextBox1.SelectAll()
End If
End Sub
怎样在VB .NET中调用记事本和计算器这个?。?呵呵,应该不难吧
先找到你要打开的应用程序的文件
然后用一个调用代码:
System.Diagnostics.Process.Start("C:\WINDOWS\system32\notepad.exe")
这是要开记事本的
System.Diagnostics.Process.Start("C:\WINDOWS\system32\calc.exe")
这是打开计算器的
应该也可以把这两个应用程序复制到你的程序的默认目录下,就是BIN下吧!
呵呵,试试?。∫壹臃峙叮 。。?
vb:简易计算器(加减乘除)代码代码如下:
Dim t, t1 As Integer
Dim x, y As Double
Public Sub com()
x = Val(l1.Caption)
Select Case t1
Case Is = 1: y = y + x
Case Is = 2: y = y - x
Case Is = 3: y = y * x
Case Is = 4: y = y / x
End Select
t1 = 0
t = 0
l1.Caption = "0"
End Sub
Private Sub Form_Load()
x = 0
y = 0
t = 0
t1 = 1
End Sub
Private Sub c0_Click(Index As Integer)
If l1.Caption = "0" Then
l1.Caption = "0"
Else
l1.Caption = l1.Caption + "0"
End If
End Sub
Private Sub C1_Click(Index As Integer)
If l1.Caption = "0" Then
l1.Caption = "1"
Else
l1.Caption = l1.Caption + "1"
End If
End Sub
Private Sub c10_Click(Index As Integer)
If t = 0 Then
l1.Caption = l1.Caption + "."
t = 1
End If
End Sub
Private Sub C2_Click(Index As Integer)
If l1.Caption = "0" Then
l1.Caption = "2"
Else
l1.Caption = l1.Caption + "2"
End If
End Sub
Private Sub C3_Click(Index As Integer)
If l1.Caption = "0" Then
l1.Caption = "3"

推荐阅读