美文网首页
练习-用户界面设计

练习-用户界面设计

作者: A_rrow | 来源:发表于2019-08-04 10:23 被阅读0次
Ag
  1. 界面跨框架搭建,将列表框放入框架中,借助框架的好处是移动时可以一起移动


    效果框

    2.展示第一个框




    3.展示第二和第三个框

逻辑:点击第一个框时,第二框会被展示,第三个框同理

完整代码

Dim arr()
Dim ID As String
Dim price As Long

Private Sub ListBox4_Click()

End Sub

Private Sub UserForm_Activate()

Dim dic As New Dictionary
arr = Sheet2.Range("a2:e" & Sheet2.Range("a65536").End(xlUp).Row)

For i = LBound(arr) To UBound(arr)
    dic(arr(i, 2)) = 1
Next
'1.展示第一个框'
Me.ListBox1.List = dic.Keys

End Sub

Private Sub ListBox1_Click()
'点击第一个框时展示第二个框'
Dim dic As New Dictionary

For i = LBound(arr) To UBound(arr)
    If arr(i, 2) = Me.ListBox1.Value Then
        dic(arr(i, 3)) = 1
    End If
Next

Me.ListBox2.List = dic.Keys
'点击第一个框时清空第三个框'
Me.ListBox3.Clear
'价格也需清空为0'
Me.Label2.Caption = 0

End Sub

Private Sub ListBox2_Click()
'点击第二框时展示第三个框
'
Dim dic As New Dictionary

For i = LBound(arr) To UBound(arr)
    If arr(i, 2) = Me.ListBox1.Value And arr(i, 3) = Me.ListBox2.Value Then
        dic(arr(i, 4)) = 1
    End If
Next

Me.ListBox3.List = dic.Keys
'价格清空为0'
Me.Label2.Caption = 0
End Sub

Private Sub ListBox3_Click()
'点击到第三个框时显示单价'
For i = LBound(arr) To UBound(arr)
    If arr(i, 2) = Me.ListBox1.Value And arr(i, 3) = Me.ListBox2.Value And arr(i, 4) = Me.ListBox3.Value Then
        ID = arr(i, 1)
        price = arr(i, 5)
    End If
Next
Me.Label2.Caption = price
End Sub

Private Sub CommandButton1_Click()
'点击选择按钮是将所选的商品放到购物篮'

'开始前加个判断,如果列表框中没东西则不执行'
If Me.ListBox1.Value <> "" And Me.ListBox2.Value <> "" And Me.ListBox3.Value <> "" And Me.TextBox1.Value > 0 Then
    '增加一个空行行'
    Me.ListBox4.AddItem
    '0行0列相当于第一行第一列'
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 0) = ID
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 1) = Me.ListBox1.Value
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 2) = Me.ListBox2.Value
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 3) = Me.ListBox3.Value
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 4) = Me.TextBox1.Value
    Me.ListBox4.List(Me.ListBox4.ListCount - 1, 5) = Me.TextBox1.Value * Me.Label2.Caption
Else

MsgBox "请正确选择商品"
End If

Private Sub CommandButton2_Click()
'删除商品'
'遍历时时从0开始'
For i = 0 To Me.ListBox4.ListCount - 1
    If Me.ListBox4.Selected(i) = True Then
        '删除后减去对应的价格'
        Me.Label5.Caption = Me.Label5.Caption - Me.ListBox4.List(i, 5)
        '移除删除后的这一行'
        Me.ListBox4.RemoveItem i
    End If
Next
End Sub

Private Sub CommandButton3_Click()
'点击结算按钮时进行结算并记录购买的数据'
'订单ID'
Dim DDID As String
Dim i
If Me.ListBox4.ListCount > 0 Then

'往下一行写数据'
i = Sheet2.Range("a65536").End(xlUp).Row + 1
DDID = "D" & Format(VBA.Now, "yyyymmddhhmmss")



For j = 0 To Me.ListBox4.ListCount - 1
Sheet2.Range("a" & i) = DDID
Sheet2.Range("b" & i) = Date
'取ID'
Sheet2.Range("c" & i) = Me.ListBox4.List(j, 0)
'取数量'
Sheet2.Range("d" & i) = Me.ListBox4.List(j, 4)
'取金额'
Sheet2.Range("e" & i) = Me.ListBox4.List(j, 5)
'下一次循环时 i 的行数是下一行 即 i + 1'
i = i + 1
Next


MsgBox "结算成功"
'关闭窗体'
Unload Me


Else

MsgBox "购物清单为空"
End If

End Sub

End Sub


相关文章

  • 练习-用户界面设计

    界面跨框架搭建,将列表框放入框架中,借助框架的好处是移动时可以一起移动效果框2.展示第一个框3.展示第二和第三个框...

  • 了解界面设计

    简说界面设计 界面设计是什么? 这里主要提到的是网页界面设计,在网页上实现的用户界面,用户在浏览页面时会受界面设计...

  • GeoQuiz项目总结

    用户界面设计Android 与MVC模式Activity生命周期第二个Activity心得体会 用户界面设计 用户...

  • 用户体验要素-笔记总结(下)

    4.框架层 界面设计、导航设计、信息设计界面设计 界面设计:提供用户做某些事的能力,通过它,用户能真正接触到那些“...

  • UI设计师必须要懂的九个设计法则

    UI设计-用户界面设计,是做用户界面设计的,所以离不开用户的体验,视觉设计可以直接影响到用户的体验,所以UI设计师...

  • 应该了解的设计法则-交互设计篇2

    嘎嘎,文章末尾有福利 用户界面设计规则从何而来? 1976年Cherition为早期的交互提出了用户界面设计准则;...

  • web的设计理论笔记

    web-ui是什么--网页的界面设计 UI就是用户界面,包括三个方向:用户研究,交互设计,界面设计。 WUI是网页...

  • UI界面创意图标如何设计

    图标是图形化用户界面设计中的重要元素之一,也是图形化用户界面设计中最直接、最生动的视觉形态,有着优秀图形化用户界设...

  • Web设计----Banner

    一、UI(user interface):用户界面设计 内容 1、GUI:图形界面设计 2、ID设计(UX国内的交...

  • 界面设计要做的全部事情就是选择正确的界面元素

    今天为大家更新《用户体验要素》的第六章——框架层,界面设计、导航设计和信息设计——界面设计 本小结关键词:界面设计...

网友评论

      本文标题:练习-用户界面设计

      本文链接:https://www.haomeiwen.com/subject/abujdctx.html