回 帖 发 新 帖 刷新版面

主题:大哥们 救命呀

大哥们
  帮帮我 作一个记事本的源程序 和一个计算器 的源程序

回复列表 (共21个回复)

沙发

自己做嘛,这都是很简单的小程序啊。

板凳

Command11  CE
Command10(0) ——Command10(9) 0-9
Command10(10) .
Command1 +
Command2 -
Command3 *
Command4 /
Command5 =
Command6 sqrt
Command7 x^y
Command8 %
Command9 abs
Text1 数字
Text2 符号

3 楼

Dim num1 As Double
Dim num2 As Double
Dim op As Integer
Dim sum As Single
Private Sub comman10_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub

Private Sub Command10_Click(Index As Integer)
Select Case Index
       Case 0
         Text1.Text = Text1.Text + "0"
       Case 1 To 9
         Text1.Text = Str$(Text1.Text + Chr$(48 + Index))
       Case 10
         Text1.Text = Text1.Text + "."
      End Select
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command1_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 1
Text2.Text = "+"
Text1.SetFocus
End Sub

Private Sub command10_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub


Private Sub command11_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command11_Click()
         Text1.Text = ""
         Text2.Text = ""
End Sub
Private Sub Command13_Click()
End
End Sub
Private Sub Command2_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 2
Text2.Text = "-"
Text1.SetFocus
End Sub
Private Sub command4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub command3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub

Private Sub Command3_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 3
Text2.Text = "*"
Text1.SetFocus
End Sub

Private Sub Command4_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 4
Text2.Text = "/"
Text1.SetFocus
End Sub

Private Sub command6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command6_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 5
Text2.Text = "sqrt"
End Sub

Private Sub command7_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command7_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 6
Text2.Text = "^"
Text1.SetFocus
End Sub
Private Sub command8_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub

Private Sub Command8_Click()
num1 = Val(Text1.Text)
Text1.Text = ""
op = 7
Text2.Text = "%"
End Sub

Private Sub command9_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command9_Click()
num1 = Val(Text1.Text)
Text1.Text = " "
op = 8
Text2.Text = "abs"
End Sub
Private Sub command5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub
Private Sub Command5_Click()
num2 = Val(Text1.Text)
Select Case op
       Case 1
        sum = num1 + num2
       Case 2
        sum = num1 - num2
       Case 3
        sum = num1 * num2
       Case 4
        sum = num1 / num2
       Case 5
        sum = Sqr(num1)
       Case 6
        sum = 1
        For i = 1 To num2
         sum = sum * num1
        Next i
       Case 7
        sum = num1 / 100
       Case 8
        sum = Abs(num1)
End Select
Text1.Text = Str$(sum)
        End Sub

Private Sub Form_Load()
num1 = 0
num2 = 0
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
       Case 16
        num1 = Val(Text1.Text)
        Text1.Text = ""
        op = 6
        Text2.Text = "^"
        Text1.SetFocus
       Case 27
         Text1.Text = ""
         Text2.Text = ""
       Case 107
         num1 = Val(Text1.Text)
         Text1.Text = ""
         op = 1
         Text2.Text = "+"
         Text1.SetFocus
         
       Case 109
         num1 = Val(Text1.Text)
                  op = 2
         Text2.Text = "-"
         Text1.SetFocus
         Text1.Text = ""

       Case 106
         num1 = Val(Text1.Text)
         Text1.Text = ""
         op = 3
         Text2.Text = "*"
         Text1.SetFocus

       Case 111

         num1 = Val(Text1.Text)
         Text1.Text = ""
         op = 4
         Text2.Text = "/"
         Text1.SetFocus

       Case 13
          
          Select Case op
                Case 1
                 num2 = Val(Text1.Text)
                 sum = num1 + num2
                Case 2
                 num2 = Val(Text1.Text)
                 sum = num1 - num2

                Case 3
                 num2 = Val(Text1.Text)
                 sum = num1 * num2

                Case 4
                
                 num2 = Val(Text1.Text)
                 sum = num1 / num2

                Case 6
                num2 = Val(Text1.Text)
                 sum = 1
                 For i = 1 To num2
                  sum = sum * num1
                 Next
End Select
Text1.Text = Str$(sum)
End Select
If KeyCode = 96 Or 97 Or 98 Or 99 Or 100 Or 101 Or 102 Or 103 Or 104 Or 105 Or 48 Or 49 Or 50 Or 51 Or 52 Or 53 Or 54 Or 55 Or 56 Or 57 Then
  If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Or Text1.Text = "^" Then Text1.Text = ""
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
         Text1.Text = ""
         Text2.Text = ""
End If
End Sub

4 楼

这个程序可以键盘输入的计算器
如有问题,告诉我一下~

5 楼

忘记说了,form的键盘优先别忘记设置~

6 楼

记事本你要什么样子的?
有空我做一下

7 楼

微软msdn源码:
' ------------------------------------------------------------------------
'               版权所有 (C) 1994 Microsoft Corporation
'
' 您可以免费以任何方式使用、修改、复制并分发您认为有用的
' 示例应用程序文件 (或任何修改过的版本)。Microsoft 对任何
' 示例应用程序文件不做任何保证,不负任何责任和义务。
' ------------------------------------------------------------------------
Option Explicit
Dim Op1, Op2                ' 预先输入操作数。
Dim DecimalFlag As Integer  ' 小数点存在吗?
Dim NumOps As Integer       ' 操作数个数。
Dim LastInput               ' 指示上一次按键事件的类型。
Dim OpFlag                  ' 指示未完成的操作。
Dim TempReadout

' C (取消) 按钮的 Click 事件过程
' 重新设置显示并初始化变量。
Private Sub Cancel_Click()
    Readout = Format(0, "0.")
    Op1 = 0
    Op2 = 0
    Form_Load
End Sub

' CE (取消输入) 按钮的 Click 事件过程。
Private Sub CancelEntry_Click()
    Readout = Format(0, "0.")
    DecimalFlag = False
    LastInput = "CE"
End Sub

' 小数点 (.) 按钮的 Click 事件过程
' 如果上一次按键为运算符,初始化 readout 为 "0.";
' 否则显示时追加一个小数点。
Private Sub Decimal_Click()
    If LastInput = "NEG" Then
        Readout = Format(0, "-0.")
    ElseIf LastInput <> "NUMS" Then
        Readout = Format(0, "0.")
    End If
    DecimalFlag = True
    LastInput = "NUMS"
End Sub

' 窗体的初始化过程
' 设置所有变量为其初始值。
Private Sub Form_Load()
    DecimalFlag = False
    NumOps = 0
    LastInput = "NONE"
    OpFlag = " "
    Readout = Format(0, "0.")
    'Decimal.Caption = Format(0, ".")
End Sub

' 数字键 (0-9) 的 Click 事件过程
' 向显示中的数追加新数。
Private Sub Number_Click(Index As Integer)
    If LastInput <> "NUMS" Then
        Readout = Format(0, ".")
        DecimalFlag = False
    End If
    If DecimalFlag Then
        Readout = Readout + Number(Index).Caption
    Else
        Readout = Left(Readout, InStr(Readout, Format(0, ".")) - 1) + Number(Index).Caption + Format(0, ".")
    End If
    If LastInput = "NEG" Then Readout = "-" & Readout
    LastInput = "NUMS"
End Sub

' 运算符 (+, -, x, /, =) 的 Click 事件过程
' 如果接下来的按键是数字键,增加 NumOps。
' 如果有一个操作数,则设置 Op1。
' 如果有两个操作数,则将 Op1 设置为 Op1 与
' 当前输入字符串的运算结果,并显示结果。
Private Sub Operator_Click(Index As Integer)
    TempReadout = Readout
    If LastInput = "NUMS" Then
        NumOps = NumOps + 1
    End If
    Select Case NumOps
        Case 0
        If Operator(Index).Caption = "-" And LastInput <> "NEG" Then
            Readout = "-" & Readout
            LastInput = "NEG"
        End If
        Case 1
        Op1 = Readout
        If Operator(Index).Caption = "-" And LastInput <> "NUMS" And OpFlag <> "=" Then
            Readout = "-"
            LastInput = "NEG"
        End If
        Case 2
        Op2 = TempReadout
        Select Case OpFlag
            Case "+"
                Op1 = CDbl(Op1) + CDbl(Op2)
            Case "-"
                Op1 = CDbl(Op1) - CDbl(Op2)
            Case "X"
                Op1 = CDbl(Op1) * CDbl(Op2)
            Case "/"
                If Op2 = 0 Then
                   MsgBox "除数不能为零", 48, "计算器"
                Else
                   Op1 = CDbl(Op1) / CDbl(Op2)
                End If
            Case "="
                Op1 = CDbl(Op2)
            Case "%"
                Op1 = CDbl(Op1) * CDbl(Op2)
            End Select
        Readout = Op1
        NumOps = 1
    End Select
    If LastInput <> "NEG" Then
        LastInput = "OPS"
        OpFlag = Operator(Index).Caption
    End If
End Sub

' 百分比键 (%) 的 Click 事件过程
' 计算并显示第一个操作数的百分数。
Private Sub Percent_Click()
    Readout = Readout / 100
    LastInput = "Ops"
    OpFlag = "%"
    NumOps = NumOps + 1
    DecimalFlag = True
End Sub

8 楼

记事本部分源码:
' 如果鼠标指针不存在于记事本的结尾处...
    If txtNote.SelStart <> Len(Screen.ActiveControl.Text) Then
        ' 如果没有进行选择, 将选项加一。
        If txtNote.SelLength = 0 Then
            txtNote.SelLength = 1
            ' 如果鼠标指针在一个空的直线上,将选相加二。
            If Asc(txtNote.SelText) = 13 Then
                txtNote.SelLength = 2
            End If
        End If
        ' 删除选定的文本
        txtNote.SelText = ""
    End If

关于剪贴板的。

9 楼

这是什么东东啊????????????

10 楼

这个做了干什么啊,计算机上不是配有这些程序,程序做出来就是让人觉得方便的,但你这个做出来了也没有用啊,还不如不做.

我来回复

您尚未登录,请登录后再回复。点此登录或注册