當前位置:編程學習大全網 - 源碼下載 - 求 VB做 計算器 屏幕保護 匯率計算 抽獎機 的代碼 簡單的就行 謝謝了啊

求 VB做 計算器 屏幕保護 匯率計算 抽獎機 的代碼 簡單的就行 謝謝了啊

' 給 LZ 壹個簡單計算器的 VB 程序吧' Command1:有11個元素,前10個元素分別表示 0~9 數字,第11個元素表示小數點。' Command2:有5個元素,各元素分別表示+、-、*、/ 和Mod 運算符。

' Command3:Caption 屬性值為 Cls。' Command4:Caption 屬性值為 =。' Command5:Caption 屬性值為 Exit。 Public a, b As DoublePublic CalKey As String Private Sub Command1_Click(Index As Integer) ' 0 1 2 3 4 5 6 7 8 9 Text1.Text = Trim(Text1.Text) If Text1.Text = "0" Then Text1.Text = "" If Index <= 9 Then Text1.Text = Text1.Text & Format(Index) ElseIf Index = 10 Then Text1.Text = Text1.Text & "." End IfEnd Sub Private Sub Command2_Click(Index As Integer) ' + - * / \ a = Val(Text1.Text) Select Case Index Case 0 CalKey = "+" Case 1 CalKey = "-" Case 2 CalKey = "*" Case 3 CalKey = "/" Case 4 CalKey = "\" End Select If Index <= 3 Then Text1.Text = "" End IfEnd Sub Private Sub Command3_Click() ' Cls Text1.Text = ""End Sub Private Sub Command4_Click() ' = b = Val(Text1.Text) Select Case CalKey Case "+" Text1.Text = a + b Case "-" Text1.Text = a - b Case "*" Text1.Text = a * b Case "/" If b <> 0 Then Text1.Text = a / b Else Text1.Text = "" MsgBox "除數不能為0" End If Case "\" If b <> 0 Then Text1.Text = a Mod b Else Text1.Text = "" MsgBox "除數不能為0" End If End Select If Left(Text1.Text, 1) = "." Then Text1.Text = "0" & Text1.TextEnd Sub Private Sub Command5_Click() unloade MeEnd Sub Private Sub Form_Load()Dim i As IntegerFor i = 0 To 9 Command1(i).Caption = Format(i)NextCommand1(10).Caption = "."For i = 0 To 4 Command2(i).Caption = Mid("+-*/\", i + 1, 1)NextCommand3.Caption = "Cls"Command4.Caption = "="Command5.Caption = "Exit"Text1.Text = ""End Sub

  • 上一篇:詢CM潤迅傳呼機的使用說明
  • 下一篇:在我們的工作中協同軟件是否必要,有哪些協同軟件比較好的?
  • copyright 2024編程學習大全網