VB
偶不会计算器的减法代码谁帮帮我,好不好? --------------------编程问答-------------------- VB计算器源代码程序: http://zhidao.baidu.com/question/20155635.html --------------------编程问答-------------------- 狂晕!!!
--------------------编程问答-------------------- 偶写了一些了
但是呢,其他的偶不会呀,那个你可以帮我继续写吗?
老师的作业太难了
偶好可怜滴哦
Dim s, k, s1
Private Sub Command1_Click()
s = Left(s, Len(s) - 1)
Text1.Text = s
End Sub
Private Sub Command10_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "6"
k = 0
Else
s = s + "6"
End If
Text1.Text = s
End Sub
Private Sub Command13_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "1"
k = 0
Else
s = s + "1"
End If
Text1.Text = s
End Sub
Private Sub Command16_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "2"
k = 0
Else
s = s + "2"
End If
Text1.Text = s
End Sub
Private Sub Command19_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "3"
k = 0
Else
s = s + "3"
End If
Text1.Text = s
End Sub
Private Sub Command2_Click()
s = ""
Text1.Text = s
End Sub
Private Sub Command23_Click()
Text1.Text = Val(s) + Val(s1)
k = 1
End Sub
Private Sub Command26_Click()
Text1.Text = Val(s) + s1
End Sub
Private Sub Command3_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "7"
k = 0
Else
s = s + "7"
End If
Text1.Text = s
End Sub
Private Sub Command4_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "8"
k = 0
Else
s = s + "8"
End If
Text1.Text = s
End Sub
Private Sub Command5_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "9"
k = 0
Else
s = s + "9"
End If
Text1.Text = s
End Sub
Private Sub Command8_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "4"
k = 0
Else
s = s + "4"
End If
Text1.Text = s
End Sub
Private Sub Command9_Click()
If k = 1 Then
s1 = Val(Text1.Text)
s = ""
s = s + "5"
k = 0
Else
s = s + "5"
End If
Text1.Text = s
End Sub
谁继续呀? --------------------编程问答-------------------- 简单撒
自己搞定 --------------------编程问答-------------------- 我真的不会呀,帮一下了,好不好呀?
谢谢.
有的人见死不救哦,我好难过...... --------------------编程问答--------------------
--------------------编程问答-------------------- 减法可以这样
Private Sub Command1_Click()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
a = 1
b = 2
c = 3
d = 2
MsgBox "a+b=" & a + b & " c-d=" & c - d, , "就是这样"
End Sub
需要先声明一个变量,用来存放是按了+-*/按钮的
dim i as integer 这个代码要放在通用部分
Private Sub Command减法_Click() ‘如果按了减法这个按钮
if k=1 then '用来判断是否已经按过=号了,k=1就是按了
,如果按了,就要重新计算,如果直接按-,那么是一个负数
if left(text1.text,1)<>"-" then’ ‘这行是来用判断是不是已经按过一次-了,要不然按两下就出现两个-
s="-"
endif
text.text=s
else
i=2 '+法时=1,-时=2,*=3,/=4
s=text1.text
text1.text=""
endif
End Sub
Private Sub Command23_Click()
Text1.Text = Val(s) + Val(s1)
k = 1
End Sub
这个应该是等于号的代码吧!这样简单是不行的吧!因为要实现+-*/呢。这个只能实现+法运算。
我给你改一下
Private Sub Command23_Click()
select case i
case 1
Text1.Text = Val(s) + Val(s1)
case 2
text1.text=val(s)- val(s1)
case 3
text1.text=val(s)* val(s1)
case 4
text1.text=val(s)/ val(s1)
endselect
k = 1
End Sub
我没有调试,按照这个思路做,应该差不多。
另外注意,这个计算器,是必须按=才能计算,连按+-*/是不能计算的! --------------------编程问答-------------------- 谢谢你们
呵呵
我做做看得不得哈 --------------------编程问答-------------------- 7楼滴
5555555
你知道吗?不得呀
我明天要交作业了
555555
死了
那个运行不了,还有搞得我 原来的+法都运行不了了
你再帮我 弄弄呀
加我QQ呀
275645722
补充:VB , 基础类