首页 计算器(用vb)代码

计算器(用vb)代码

举报
开通vip

计算器(用vb)代码计算器(用vb)代码 计算器(用vb)代码 Dim dflag As Integer Dim I As Integer Dim opnre As Integer Dim prev As Double Dim oflag As Integer Dim ind As Integer Dim soundbz As Boolean Dim ProgramPath As String Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd...

计算器(用vb)代码
计算器(用vb)代码 计算器(用vb)代码 Dim dflag As Integer Dim I As Integer Dim opnre As Integer Dim prev As Double Dim oflag As Integer Dim ind As Integer Dim soundbz As Boolean Dim ProgramPath As String Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal Cx As Long, ByVal Cy As Long, ByVal wFlags As Long) As Long Public Sub SetOnTop(ByVal IsOnTop As Integer) Dim rtn As Long If IsOnTop = 1 Then '将窗口置于最上面 rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) Else rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3) End If End Sub Private Sub Check1_Click() If Check1.Value = 1 Then SetOnTop 1 Else SetOnTop 0 End If End Sub Private Sub Command1_Click(Index As Integer) text1 = Trim(text1) If Len(text1) > 20 Then Beep Exit Sub End If soundbz = False MMControl1.Command = "Close" MMControl1.FileName = ProgramPath & "/声音文件/" & Index & ".wav" MMControl1.Command = "Open" MMControl1.Command = "Play" If ind = 4 Then prev = 0 text1.Caption = " " ind = 0 End If opnre = 0 If oflag = 0 Then text1.Caption = " " End If oflag = 1 If Command1(Index).Caption <> "." Then If text1.Caption <> " 0" Then text1.Caption = text1.Caption & Command1(Index).Caption Text = Mid(text1, 1, 1) If Text = "." Then text1 = "0" & text1 End If Else text1.Caption = " " & Command1(Index).Caption End If Else If dflag = 0 Then text1.Caption = text1.Caption & "." dflag = 1 Else Command6.SetFocus Exit Sub End If End If Command6.SetFocus End Sub Private Sub Command1_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 End Sub Private Sub Command2_Click(Index As Integer) soundbz = False MMControl1.Command = "Close" If Index = 0 Then MMControl1.FileName = ProgramPath & "/声音文件/加.wav" If Index = 1 Then MMControl1.FileName = ProgramPath & "/声音文件/减.wav" If Index = 3 Then MMControl1.FileName = ProgramPath & "/声音文件/乘.wav" If Index = 2 Then MMControl1.FileName = ProgramPath & "/声音文件/除.wav" If Index = 4 Then MMControl1.FileName = ProgramPath & "/声音文件/等于.wav" soundbz = True End If MMControl1.Command = "Open" MMControl1.Command = "Play" If opnre = 0 Or Index = 4 Then If ind = 0 Then prev = prev + Val(text1.Caption) ElseIf ind = 1 Then prev = prev - Val(text1.Caption) ElseIf ind = 2 Then If Val(text1.Caption) = 0 Then text1 = "错误~" Beep Command6.SetFocus Exit Sub Else prev = prev / Val(text1.Caption) End If ElseIf ind = 3 Then prev = prev * Val(text1.Caption) End If text1.Caption = Str(prev) oflag = 0 End If opnre = 1 ind = Index dflag = 0 Command6.SetFocus If Index = 4 Then If Option1.Value = True Then text1 = Trim(Round(text1, 2)) If Option2.Value = True Then text1 = Trim(Round(text1, 3)) If Option3.Value = True Then text1 = Trim(Round(text1, 4)) If Option4.Value = True Then text1 = Trim(text1) If text1 <> 0 Then Text = Mid(text1, 1, 1) If Text = "." Then text1 = "0" & text1 End If End If ls = Len(text1) If ls <> 0 Then For I = 1 To ls t = Mid(text1, I, 1) DoEvents Do While (MMControl1.Mode <> 525) And soundbz DoEvents Loop MMControl1.Command = "Close" If t <> "." Then If t = "-" Then MMControl1.FileName = ProgramPath & "/声音文件/负.wav" Else MMControl1.FileName = ProgramPath & "/声音文件/" & t & ".wav" End If Else MMControl1.FileName = ProgramPath & "/声音文件/10.wav" End If MMControl1.Command = "Open" MMControl1.Command = "Play" Next I End If End If End Sub Private Sub Command2_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 End Sub Private Sub Command3_Click()soundbz = False MMControl1.Command = "Close" MMControl1.FileName = ProgramPath & "/声音文件/归零.wav" MMControl1.Command = "Open" MMControl1.Command = "Play" text1.Caption = " 0" Command6.SetFocus End Sub Private Sub Command3_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 End Sub Private Sub Command4_Click() soundbz = False MMControl1.Command = "Close" MMControl1.FileName = ProgramPath & "/声音文件/清除.wav" MMControl1.Command = "Open" MMControl1.Command = "Play" dflag = 0 prev = 0 oflag = 0 ind = 0 opnre = 0 text1.Caption = " 0" Command6.SetFocus End Sub Private Sub Command4_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 End Sub Private Sub Command5_Click() soundbz = False SaveSetting App.EXEName, "保留", "n1", Option1.Value SaveSetting App.EXEName, "保留", "n2", Option2.Value SaveSetting App.EXEName, "保留", "n3", Option3.Value SaveSetting App.EXEName, "保留", "n4", Option4.Value SaveSetting App.EXEName, "置顶", "yorn", Check1.Value ' MMControl1.Command = "Close" Unload Me End Sub Private Sub Command5_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 End Sub Private Sub Command6_Click() Command2_Click (4) End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If text1 = "错误~" Then Command4_Click End If If KeyAscii = Asc(".") Then I = 10 Command1_Click (I) ElseIf KeyAscii = Asc("0") Then I = 0 Command1_Click (I) ElseIf KeyAscii = Asc("1") Then I = 1 Command1_Click (I) ElseIf KeyAscii = Asc("2") Then I = 2 Command1_Click (I) ElseIf KeyAscii = Asc("3") Then I = 3 Command1_Click (I) ElseIf KeyAscii = Asc("4") Then I = 4 Command1_Click (I) ElseIf KeyAscii = Asc("5") Then I = 5 Command1_Click (I) ElseIf KeyAscii = Asc("6") Then I = 6 Command1_Click (I) ElseIf KeyAscii = Asc("7") Then I = 7 Command1_Click (I) ElseIf KeyAscii = Asc("8") Then I = 8 Command1_Click (I) ElseIf KeyAscii = Asc("9") Then I = 9 Command1_Click (I) ElseIf KeyAscii = Asc("0") Then I = 0 Command1_Click (I) ElseIf KeyAscii = Asc("+") Then I = 0 Command2_Click (I) ElseIf KeyAscii = Asc("+") Then I = 0 Command2_Click (I) ElseIf KeyAscii = Asc("-") Then I = 1 Command2_Click (I) ElseIf KeyAscii = Asc("/") Then I = 2 Command2_Click (I) ElseIf KeyAscii = Asc("*") Then I = 3 Command2_Click (I) ElseIf KeyAscii = Asc("=") Or KeyAscii = 13 Then I = 4 Command2_Click (I) ElseIf KeyAscii = Asc("c") Or KeyAscii = Asc("C") Or KeyAscii = 27 Then Command4_Click ElseIf KeyAscii = Asc("d") Or KeyAscii = Asc("D") Then Command3_Click End If End Sub Private Sub Form_Load() If App.PrevInstance = True Then Unload Me MsgBox "程序正在运行,不可重复运行多个~", 64, "系统提示" End End If soundbz = True dflag = 0 prev = 0 oflag = 0 ind = 0 opnre = 0 Clipboard.Clear MMControl1.DeviceType = "WaveAudio" ProgramPath = App.Path Option1.Value = GetSetting(App.EXEName, "保留", "n1", True) Option2.Value = GetSetting(App.EXEName, "保留", "n2", False) Option3.Value = GetSetting(App.EXEName, "保留", "n3", False) Option4.Value = GetSetting(App.EXEName, "保留", "n4", False) Check1.Value = GetSetting(App.EXEName, "置顶", "yorn", 0) End Sub Private Sub Form_Unload(Cancel As Integer) MMControl1.Command = "Close" End End Sub Private Sub text1_Click()
本文档为【计算器&#40;用vb&#41;代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_435706
暂无简介~
格式:doc
大小:32KB
软件:Word
页数:0
分类:互联网
上传时间:2017-09-28
浏览量:24