⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 velp12.htm

📁 简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<NOTE>27: Make sure that each cell is wide enough to hold all data and titles.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>28: Continue the loop.<BR><P>29: Terminate the subroutine.<BR><P>30: A blank line to separate the procedures.<BR><P>31: The code for the subroutine procedure that initializes all the titles in the grid's fixed rows and columns.<BR><P>32: A remark explains the procedure.<BR><P>33: Set up for the first row (row number 0).<BR><P>34: Set up for the second column (column number 1).<BR><P>35: Assign a title.<BR><P>36: Move to the next column in the same row.<BR><P>37: Assign a title.<BR><P>38: A remark to explain that not all the code is shown.<BR><P>39: A remark explains the code.<BR><P>40: Set up for the first column (column number 0).<BR><P>41: Set up for the second row (row number 1).<BR><P>42: Assign a title.<BR><P>43: Move to the next row in the same column.<BR><P>44: Assign a title.<BR><P>45: A remark to explain that not all the code is shown.<BR><P>46: Terminates the subroutine.<BR><P>47: A blank line to separate the procedures.<BR><P>48: The code for the subroutine procedure that initializes all the values in the grid's nonfixed cells.<BR><P>49: A remark explains the procedure.<BR><P>50: The remark continues.<BR><P>51: The remark continues.<BR><P>52: The remark continues.<BR><P>53: The remark continues.<BR><P>54: Set up for the second row (the first nonfixed row).<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>54: The Row and Col properties determine which cell gets the next value.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>55: Set up for the second column (the first nonfixed column).<BR><P>56: Assign a price value.<BR><P>57: Move to the next column.<BR><P>58: Assign a price value.<BR><P>59: Move to the next column.<BR><P>60: Assign a price value.<BR><P>61: Move to the next column.<BR><P>62: Assign a price value.<BR><P>63: Move to the next column.<BR><P>64: Assign a price value.<BR><P>65: Move to the next row.<BR><P>66: Move to the next column.<BR><P>67: Assign a price value.<BR><P>68: A remark to explain that not all code is listed here.<BR><P>69: Terminate the subroutine.<BR><BR><A NAME="E69E172"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Using the Command Buttons and Scroll Bars</B></FONT></CENTER></H4><BR><P>The application is set up to allow the user to select one or more cells with the mouse and then update the price values for only those selected cells. The user can thus try various pricing scenarios to see which pricing structure works best for specific applications. When the user clicks either command button, the selected cell or cells all increase or decrease by the amount shown on the command button at the time of the click. All unselected cells remain unaffected by the price change.<BR><P>The scroll bars affect the price of the change as well as the captions on the command buttons themselves. For example, if the user lowers the value of the Decrease scroll bar, the Decrease by... command button's caption changes accordingly. The next time the user clicks the command button, the selected cells will decrease in price by the amount indicated on the scroll bar. The code in Listing P12.3 describes the interaction between the two scroll bars and their appropriate command buttons.<BR><P><FONT COLOR="#000080"><B>Listing P12.3. Managing the price changes through scroll bars, command buttons, and selected cells.</B></FONT><BR><PRE><FONT COLOR="#000080">1: Sub hscDecrease_Change ()2: ' Change the command button's caption3: cmdDecrease.Caption = &quot;&amp;Decrease by&quot; &amp; Str$(hscDecrease.Value) &amp; &quot;%&quot;4: End Sub5:6: Sub hscIncrease_Change ()7: ' Change the command button's caption8: cmdIncrease.Caption = &quot;&amp;Increase by&quot; &amp; Str$(hscIncrease.Value) &amp; &quot;%&quot;9: End Sub10:11: Sub cmdDecrease_Click ()12: ' Decrease selected cell values13: ' by the decreasing scroll bar percentage14: Dim SelRows, SelCols As Integer15: If (grdLawn.HighLight) Then ' If true...16: For SelRows = grdLawn.SelStartRow To grdLawn.SelEndRow17: For SelCols = grdLawn.SelStartCol To grdLawn.SelEndCol18: grdLawn.Row = SelRows19: grdLawn.Col = SelCols20: ' Decrease the cell by scroll bar amount21: grdLawn.Text = grdLawn.Text - (hscDecrease.Value / 100 * grdLawn.Text)22: grdLawn.Text = Format(grdLawn.Text, &quot;Fixed&quot;)23: Next SelCols24: Next SelRows25: End If26: End Sub27:28: Sub cmdIncrease_Click ()29: ' Increase selected cell values30: ' by the amount of the increase scroll bar's percentage31: Dim SelRows, SelCols As Integer32: If (grdLawn.HighLight) Then ' If true...33: For SelRows = grdLawn.SelStartRow To grdLawn.SelEndRow34: For SelCols = grdLawn.SelStartCol To grdLawn.SelEndCol35: grdLawn.Row = SelRows36: grdLawn.Col = SelCols37: ' Increase the cell by scroll bar amount38: grdLawn.Text = grdLawn.Text * (1 + hscIncrease.Value / 100)39: grdLawn.Text = Format(grdLawn.Text, &quot;Fixed&quot;)40: Next SelCols41: Next SelRows42: End If43: End Sub44:45: Sub cmdExit_Click ()46: End47: End Sub</FONT></PRE><BR><A NAME="E69E173"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Description</B></FONT></CENTER></H4><BR><P>1: The code for the event procedure that executes when the user changes the decreasing scroll bar.<BR><P>2: A remark explains the procedure.<BR><P>3: Change the command button's caption to reflect the new percentage decrease.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>3: One event procedure can change the property values of another.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>4: Terminate the procedure.<BR><P>5: A blank line separates the procedures.<BR><P>6: The code for the event procedure that executes when the user changes the increasing scroll bar.<BR><P>7: A remark explains the procedure.<BR><P>8: Change the command button's caption to reflect the new percentage increase.<BR><P>9: Terminate the procedure.<BR><P>10: A blank line separates the procedures.<BR><P>11: The code for the event procedure that executes when the user clicks the Decrease command button.<BR><P>12: A remark that explains the event procedure.<BR><P>13: The remark continues.<BR><P>14: Define two variables that control the selected cells.<BR><P>15: If there are highlighted cells...<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>15: There are no selected cells if no cells are highlighted.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>16: Step through the selected rows.<BR><P>17: Step through the selected columns.<BR><P>18: Set the row to be changed.<BR><P>19: Set the column to be changed.<BR><P>20: A remark explains the code.<BR><P>21: Update the cell's value by the amount of the decrease.<BR><P>22: Format the cell to two decimal places.<BR><P>23: Continue stepping through the selected columns.<BR><P>24: Continue stepping through the selected rows.<BR><P>25: Terminate the If statement.<BR><P>26: Terminate the procedure.<BR><P>27: A blank line separates the procedures.<BR><P>28: The code for the event procedure that executes when the user clicks the Increase command button.<BR><P>29: A remark that explains the event procedure.<BR><P>30: The remark continues.<BR><P>31: Defines two variables that control the selected cells.<BR><P>32: If there are highlighted cells...<BR><P>33: Step through the selected rows.<BR><P>34: Step through the selected columns.<BR><P>35: Set the row to be changed.<BR><P>36: Set the column to be changed.<BR><P>37: A remark explains the code.<BR><P>38: Update the cell's value by the amount of the increase.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>38: Does not affect any cells that are unselected.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>39: Format the cell to two decimal places.<BR><P>40: Continue stepping through the selected columns.<BR><P>41: Continue stepping through the selected rows.<BR><P>42: Terminate the If statement.<BR><P>43: Terminate the procedure.<BR><P>44: A blank line separates the procedures.<BR><P>45: The code for the event procedure that executes when the user clicks the Exit command button.<BR><P>46: Terminate the program.<BR><P>47: Terminate the procedure.<BR><BR><A NAME="E69E174"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Close the Application</B></FONT></CENTER></H4><BR><P>You can now exit the application and exit Visual Basic. Congratulations! You are now a Visual Basic programmer!<P ALIGN=LEFT><A HREF="vel24.htm" TARGET="_self"><IMG SRC="purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A><A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A><A HREF="index.htm" TARGET="_self"><IMG SRC="purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A><A HREF="velxa.htm" TARGET="_self"><IMG SRC="purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -