使用 Excel 制作小超市收银系统

2025-10-19 16:54:07

1、打开 Excel 将商品信息输入到 Excel 中的 Sheet2 中

使用 Excel 制作小超市收银系统

2、在 Excel 的 Sheet1 中最上面放一个输入框,用于输入条码或者扫描条码

使用 Excel 制作小超市收银系统

3、在 Excel 的 Sheet1 中最上面放一个用于清零的按钮

使用 Excel 制作小超市收银系统

4、双击这个“清零”按钮,打开VBA编辑窗口

将其中自动生成的如下2行

Private Sub CommandButton1_Click()

End Sub

换成输入如下的内容:

Private Sub CommandButton1_Click()

    For i = 4 To 100

        If Me.Cells(i, 1) Is Nothing Then

            Me.Cells(i, 2).Value = ""

            Me.Cells(i, 3).Value = ""

            Me.Cells(4, 2).Value = "合计"

            Me.Cells(4, 3).Value = 0#

            Exit For

        End If

        If Me.Cells(i, 1).Value = "" Then

            Me.Cells(i, 2).Value = ""

            Me.Cells(i, 3).Value = ""

            Me.Cells(4, 2).Value = "合计"

            Me.Cells(4, 3).Value = 0

            Exit For

        End If

        Me.Cells(i, 1).Value = ""

        Me.Cells(i, 2).Value = ""

        Me.Cells(i, 3).Value = ""

    Next

     TextBox1.Text = ""

     Image1.Picture = Nothing

End Sub

Private Sub TextBox1_Change()

    If TextBox1.Text = "" Then

        Exit Sub

    End If

    For i = 1 To 100

        If Sheet2.Cells(i, 1).Value = TextBox1.Text Then

            AddProd i

            TextBox1.Text = ""

            Exit For

        End If

        'MsgBox (Sheet2.Cells(i, 1).Value)

        If Sheet2.Cells(i, 1) Is Nothing Then

           Exit For

        End If

    Next

End Sub

Private Sub AddProd(ByVal index As Integer)

    For i = 4 To 100

        If Me.Cells(i, 1) Is Nothing Then

           Me.Cells(i, 1).Value = TextBox1.Text

           Me.Cells(i, 2).Value = Sheet2.Cells(index, 2).Value

           Me.Cells(i, 3).Value = Sheet2.Cells(index, 3).Value

           Me.Cells(i + 1, 2).Value = "合计"

           Me.Cells(i + 1, 3).Value = "=sum(C4:C" & i & ")"

           Image1.Picture = LoadPicture(Sheet2.Cells(index, 4).Value)

           Exit For

        End If

        If Me.Cells(i, 1).Value = "" Then

            Me.Cells(i, 1).Value = TextBox1.Text

           Me.Cells(i, 2).Value = Sheet2.Cells(index, 2).Value

           Me.Cells(i, 3).Value = Sheet2.Cells(index, 3).Value

           Me.Cells(i + 1, 2).Value = "合计"

           Me.Cells(i + 1, 3).Value = "=sum(C4:C" & i & ")"

           Image1.Picture = LoadPicture(Sheet2.Cells(index, 4).Value)

           Exit For

        End If

    Next

End Sub

5、返回 Excel

选择“文件”菜单中的“关闭并返回到 Microsoft Excel(C)   Atl+Q”

或者按 Atl+Q 组合键返回 Excel。

使用 Excel 制作小超市收银系统

6、从设计模式退出开始收银

点击“控件工具箱”中的设计模式图标(红色箭头所指),从设计模式退出,进入正常收银模式。可以开始收银乐。

搞定!

使用 Excel 制作小超市收银系统

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢