结账之SSTab

前端之家收集整理的这篇文章主要介绍了结账之SSTab前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

刚打开结账窗体,就看到一个既陌生又亲切的控件---SSTab,记得在敲VB百例的时候,用过这个控件,今天看到它的时候一点都想不起来它叫什么来着,通过翻阅师姐的博客,才知道原来它就叫做SStab,是部件中的一个控件。


加载工程→部件→控件 中勾选“Microsoft Tabbed Dialog Control”控件,点击应用

介绍SSTab控件提供了一组选项卡,每个都充当一个容器,包含了其他的控件。控件中每次只有一个选项卡是活动的,给用户提供了其所包含的控件,而其他选项卡都是隐藏的。


用法

Private Sub SSTab1_Click(PrevIoUsTab As Integer)

  1. Dim sum As Long,sum1 As Long,sum2 As Long
  2. Dim i As Long
  3. <span style="color:#009900;">'选择sstab的各个选项卡</span>
  4. <strong>Select Case SSTab1.Tab
  5. Case 0 <span style="color:#009900;">'购卡</span></strong>
  6. <span style="color:#009900;">'从数据库中选择对应用户内容</span>
  7. txtsql1 = "select * from student_info where userid='" & Trim(combouserID.Text) & "'"
  8. Set mrc1 = Executesql(txtsql1,Msgtext)
  9. With myflexgrid1
  10. .Rows = 1
  11. .TextMatrix(0,0) = "学号"
  12. .TextMatrix(0,1) = "卡号"
  13. .TextMatrix(0,2) = "日期"
  14. .TextMatrix(0,3) = "时间"
  15. .TextMatrix(0,4) = "金额"
  16. Do While Not mrc1.EOF
  17. .Rows = .Rows + 1
  18. .CellAlignment = 4
  19. .TextMatrix(.Rows - 1,0) = mrc1.Fields(1)
  20. .TextMatrix(.Rows - 1,1) = mrc1.Fields(0)
  21. .TextMatrix(.Rows - 1,2) = mrc1.Fields(12)
  22. .TextMatrix(.Rows - 1,3) = mrc1.Fields(13)
  23. .TextMatrix(.Rows - 1,4) = mrc1.Fields(7)
  24. mrc1.MoveNext
  25. Call AdjustColWidth(frmcheckoutaccount,myflexgrid1) <span style="color:#009900;">'自定调节myflexgrid的列宽</span>
  26. Loop
  27. End With
  28. <strong>Case 1 <span style="color:#009900;">'充值</span></strong>
  29. txtsql2 = "select * from recharge_info where userid='" & Trim(combouserID.Text) & "'"
  30. Set mrc2 = Executesql(txtsql2,Msgtext)
  31. With myflexgrid2
  32. .Rows = 1
  33. .TextMatrix(0,2) = "充值金额"
  34. .TextMatrix(0,3) = "日期"
  35. .TextMatrix(0,4) = "时间"
  36. Do While Not mrc2.EOF
  37. .Rows = .Rows + 1
  38. .CellAlignment = 4
  39. .TextMatrix(.Rows - 1,0) = mrc2.Fields(1)
  40. .TextMatrix(.Rows - 1,1) = mrc2.Fields(2)
  41. .TextMatrix(.Rows - 1,2) = mrc2.Fields(3)
  42. .TextMatrix(.Rows - 1,3) = mrc2.Fields(4)
  43. .TextMatrix(.Rows - 1,4) = mrc2.Fields(5)
  44. mrc2.MoveNext
  45. Call AdjustColWidth(frmcheckoutaccount,myflexgrid2) <span style="color:#009900;"> '自定调节myflexgrid的列宽</span>
  46. Loop
  47. End With
  48. <strong> Case 2 <span style="color:#009900;"> '退卡</span></strong>
  49. txtsql3 = "select * from cancelcard_info where userid='" & Trim(combouserID.Text) & "'"
  50. Set mrc3 = Executesql(txtsql3,Msgtext)
  51. With myflexgrid3
  52. .Rows = 1
  53. .TextMatrix(0,4) = "退卡金额"
  54. Do While Not mrc3.EOF
  55. .Rows = .Rows + 1
  56. .CellAlignment = 4
  57. .TextMatrix(.Rows - 1,0) = mrc3.Fields(0)
  58. .TextMatrix(.Rows - 1,1) = mrc3.Fields(1)
  59. .TextMatrix(.Rows - 1,2) = mrc3.Fields(3)
  60. .TextMatrix(.Rows - 1,3) = mrc3.Fields(4)
  61. .TextMatrix(.Rows - 1,4) = mrc3.Fields(2)
  62. mrc3.MoveNext
  63. Call AdjustColWidth(frmcheckoutaccount,myflexgrid3) <span style="color:#009900;">'自定调节myflexgrid的列宽</span>
  64. Loop
  65. End With
  66. <strong> Case 3 <span style="color:#009900;">'临时用户</span></strong>
  67. txtsql4 = "select * from student_info where userid='" & Trim(combouserID.Text) & "' and type='临时用户'"
  68. Set mrc4 = Executesql(txtsql4,Msgtext)
  69. With myflexgrid4
  70. .Rows = 1
  71. .TextMatrix(0,4) = "金额"
  72. Do While Not mrc4.EOF
  73. .Rows = .Rows + 1
  74. .CellAlignment = 4
  75. .TextMatrix(.Rows - 1,0) = mrc4.Fields(1)
  76. .TextMatrix(.Rows - 1,1) = mrc4.Fields(0)
  77. .TextMatrix(.Rows - 1,2) = mrc4.Fields(12)
  78. .TextMatrix(.Rows - 1,3) = mrc4.Fields(13)
  79. .TextMatrix(.Rows - 1,4) = mrc4.Fields(7)
  80. mrc4.MoveNext
  81. Call AdjustColWidth(frmcheckoutaccount,myflexgrid4) <span style="color:#009900;">'自定调节myflexgrid的列宽</span>
  82. Loop
  83. End With
  84. <strong> Case 4 <span style="background-color: rgb(255,255);"><span style="color:#009900;"> '汇总</span></span></strong>
  85. txtsellcardcount.Text = myflexgrid1.Rows - 1 <span style="background-color: rgb(255,255);"><span style="color:#009900;"> '售卡数</span></span>
  86. txtcancelcardcount.Text = myflexgrid3.Rows - 1 <span style="color:#009900;"> '退卡数</span>
  87. txtallsellcard.Text = Val(txtsellcardcount.Text) - Val(txtcancelcardcount.Text) <span style="color:#009900;"> '总售卡数</span>
  88. <span style="color:#009900;">'充值金额</span>
  89. For i = 1 To myflexgrid2.Rows - 1
  90. sum = sum + Val(myflexgrid2.TextMatrix(i,2))
  91. Next
  92. txtpay.Text = sum
  93. <span style="color:#009900;"> '退卡金额</span>
  94. For i = 1 To myflexgrid3.Rows - 1
  95. sum1 = sum1 + Val(myflexgrid3.TextMatrix(i,4))
  96. Next
  97. txtcancelcardpay.Text = sum1
  98. <span style="color:#009900;">'临时收取金额</span>
  99. For i = 1 To myflexgrid4.Rows - 1
  100. sum2 = sum2 + Val(myflexgrid4.TextMatrix(i,4))
  101. Next
  102. txtlspay.Text = sum2
  103. txtcountpay.Text = sum - sum1
  104. <strong>Case 5 </strong><span style="color:#009900;">'退出</span>
  105. Unload Me
  106. <strong>End Select
  107. End Sub</strong>

总结:当遇到一个陌生的事物时,就要慢慢去摸索、探究,在我们的不断努力下,它们就会甘拜下风,为我们所用,学习是这样,生活亦是这样,加油!

猜你在找的VB相关文章