From jacobson@math-cs.cns.uni.edu Wed Jun 26 14:52:31 2002 Date: Wed, 26 Jun 2002 14:51:31 -0500 (CDT) From: Mark Jacobson To: 810-030-01@uni.edu Subject: Page 144, Project #2 due Friday, NOT Thursday... Hi VB students, The Pre-emergence and Fertilizer assignment from page 144, project #2 is a continuation of one of your last assignments. It uses a ListBox control to store allow the user to choose either of the two standard treatments Pre-emergence or Fertilizer. It has the $0.001 and the $0.004 costs that require you to AVOID the Format( txtTreatmentCostPerSquareFoot.Text, "Currency") Because of this, I am making it due on Friday instead of being due on Thursday. Extend the due date until Friday. We have a quiz on Friday too. Quiz #2 this Friday. Here is another version of handling the less than $0.01 problem where the treatment cost is less than one penny. It was handed out today in class. -------------------------------------------------------------------------- Private Sub FormatCostPerSquareFoot2() ' Get rid of the leading dollar sign, if necessary... If Left(txtSquareFootCost, 1) = "$" Then nStr = Mid(txtSquareFootCost, 2, Len(txtSquareFootCost) - 1) Else nStr = txtSquareFootCost End If ' Convert the String to a Double value, so arithmetic can be done ' and the price of the lawn treatment can be calculated... n = CDbl(nStr) ' Note: Use n for any calculations and arithmetic ' Less than one penny, just put a $ in front of it with concatenate ' Else (otherwise) okay to use Format(). If n < 0.01 Then txtSquareFootCost = "$" & n Else txtSquareFootCost = Format(n, "Currency") ' Works fine if ' greater than 1 cent! End If End Sub Private Sub cmdDemoFormatSquareFootCost_Click() FormatCostPerSquareFoot2 End Sub -------------------------------------------------------------------------- We started to talk about Control Arrays today, and a control array of Labels was demonstrated. lblUNI(0) had .Caption of U lblUNI(1) had .Caption of N lblUNI(2) had .Caption of I The Timer1 object had .Enabled = True and .Interval = 1000 The Dancing UNI letters application code you saw, in preparation for tommorrow's (Thursday) hands-on class in Wright 339 lab was: ' This program does the following 3 actions for each of the ' three letters U, N and I stored in the Control Array lblUNI ' Note: lblUNI(0) displays U ' lblUNI(1) displays N ' lblUNI(2) displays I ' 1. Randomly change the Alignment to either 0 - Left Justify, ' 1 - Right Justify ' or 2 - Centered ' 2. Randomly choose one of 16 different colors for each letter ' 3. Randomly choose a font size between 8 and 57 inclusive Private Sub Timer1_Timer() For i = 0 To 2 lblUNI(i).Alignment = Int(Rnd * 3) lblUNI(i).ForeColor = QBColor(Int(Rnd * 16)) lblUNI(i).FontSize = Int(Rnd * 50 + 8) Next i End Sub Mark