Page 151 - Open Soource Technologies 304.indd
P. 151

Unit 6: VB Control Structure





























                     Object                Property           Setting

                     frmIndex              Text               For index = 0 To n Step s
                     lblN txtEnd           Text               n:
                     lblS txtStep          Text               s:
                     btnDisplay            Text               Display Values of Index
                     lstValues

               Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
                 ‘Display values of index ranging from 0 to n Step s
                 Dim n, s, As Double
                 Dim index As Double
                 n = CDbl(txtEnd.Text)
                 s = CDbl(txtStep.Text)
                 lstValues.Items.Clear()
                 For index = 0 To n Step s
                   lstValues.Items.Add(index)
                 Next
               End Sub

               [Run, type 3.2 and .5 into the text boxes, and click the button.]











                                      LOVELY PROFESSIONAL UNIVERSITY                        145
   146   147   148   149   150   151   152   153   154   155   156