Chapter 5 Code
Chapter 5 Code
strSQL = "Select * from tblCustomers WHERE CustomerState = '" & strState & "';"
objConn.Open (strConn)
objConn.Mode = adModeRead
objRST.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic
objRST.MoveFirst
While Not objRST.EOF
Debug.Print objRST.Fields("CustomerName")
Debug.Print objRST.Fields("CustomerState")
Debug.Print objRST.Fields("CustomerCountry")
objRST.MoveNext
Wend
objRST.Close
objConn.Close
Set objRST = Nothing
Set objConn = Nothing
End Sub
Sub CoffeeTime()
Dim curLatteAllowance As Currency
Dim curLattePrice As Currency
Dim intNumLattes As Integer
Dim curTotalExpenses As Currency
curLattePrice = 3.5
curLatteAllowance = InputBox("Enter the amount of money you have for lattes." _
, "Latte Allowance")
While curTotalExpenses < curLatteAllowance
intNumLattes = intNumLattes + 1
curTotalExpenses = curTotalExpenses + curLattePrice
Wend
Debug.Print intNumLattes
MsgBox "You can purchase " & intNumLattes & " lattes.", _
vbOKOnly, "Total Lattes"
End Sub