| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 840 人关注过本帖
标题:个位大侠帮个忙,帮小弟我实现下面VB计算器的连加连减!谢谢
只看楼主 加入收藏
lyi0627
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-18
收藏
 问题点数:0 回复次数:1 
个位大侠帮个忙,帮小弟我实现下面VB计算器的连加连减!谢谢
Option Explicit
Dim sz As Integer
Dim X As Single, Y As Single


Private Sub chengxu_Click()
indexcounter.Show
Me.Hide
End Sub

Private Sub Command1_Click()
Text1.Text = Text1.Text & "1"

End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text & "0"

End Sub

Private Sub Command10_KeyDown(KeyCode As Integer, Shift As Integer)
Text1.Text = Text1.Text & "0"
End Sub

Private Sub Command11_Click()
Text1.Text = Text1.Text & "00"

End Sub

Private Sub Command12_Click()
Text1.Text = Text1.Text & "."

End Sub

Private Sub Command13_Click()
X = CSng(Text1.Text)
sz = 1
Text1.Text = ""
End Sub

Private Sub Command14_Click()
X = CSng(Text1.Text)
sz = 2
Text1.Text = ""

End Sub

Private Sub Command15_Click()
X = CSng(Text1.Text)
sz = 3
Text1.Text = ""

End Sub

Private Sub Command16_Click()
X = CSng(Text1.Text)
sz = 4
Text1.Text = ""

End Sub

Private Sub Command17_Click()
X = CSng(Text1.Text)
sz = 5
Text1.Text = ""

End Sub

Private Sub Command18_Click()
X = CSng(Text1.Text)
Text1.Text = Sqr(X)
End Sub

Private Sub Command19_Click()
On Error GoTo ex
Y = CSng(Text1.Text)
Select Case sz
Case 1
Text1.Text = X + Y
Case 2
Text1.Text = X - Y
Case 3
Text1.Text = X * Y
Case 4
Text1.Text = X / Y
Case 5
Text1.Text = X Mod Y
End Select
ex:

End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text & "2"

End Sub

Private Sub Command20_Click()
Text1.Text = ""
End Sub

Private Sub Command21_Click()
Unload Me
End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text & "3"

End Sub

Private Sub Command4_Click()

Text1.Text = Text1.Text & "4"
End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text & "5"

End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text & "6"

End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text & "7"

End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text & "8"

End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text & "9"

End Sub
搜索更多相关主题的帖子: 计算器 
2007-12-18 14:00
沦落地球
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-9-29
收藏
得分:0 
用控件数组....
Private Sub Command1_Click(Index As Integer)
if text1.text="" then
  text1.text=cstr(index)
else
  text1.text=text1.text&cstr(index)
end if
end sub

[[italic] 本帖最后由 沦落地球 于 2007-12-18 20:58 编辑 [/italic]]
2007-12-18 20:54
快速回复:个位大侠帮个忙,帮小弟我实现下面VB计算器的连加连减!谢谢
数据加载中...
 
   



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

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