158 CHAPTER 5 STORING AND RETRIEVING APPLICATION (Web space)
158 CHAPTER 5 STORING AND RETRIEVING APPLICATION DATA Next, add the following statements to the method belonging to the DecimalButton control. Dim intResult As Integer If intResult = Instr(OutputField.Text, “.”) Then OutputField.Text = OutputField.Text + Me.Caption End If The first statement defines a local variable named intResult. The If Then block that follows uses the Instr function to determine whether a decimal has already been entered before appending a decimal character to whatever text is stored in the EditField control. In other words, because a number can only have a maximum of 1 decimal, the If Then statement prevents the user from accidentally entering a second decimal when keying in a number. Likewise, add the following code to the PushButton controls representing plus, minus, multiplication, and division buttons. OutputField.Text = OutputField.Text + ” ” + Me.Caption + ” ” PlusButton.Enabled = False MinusButton.Enabled = False DivisionButton.Enabled = False MultiplicationButton.Enabled = False The first statement adds a plus (+) character to the string displayed in the EditField control. Note, this statement also adds a blank space before and after the plus character. The next four statements disabled the buttons representing the plus, minus, division, and multiplication buttons. Remember, the RBCalculator only supports one calculation at a time, which is enforced by disabling these buttons as soon as the user clicks one of them. These buttons are reenabled later when the user clicks the Clear button to allow a new equation to be entered. Another limitation of the RBCalculator is that is only lets you work with one decimal number as a time. Next, add the following code statements to the PushButton control representing the equals button. Dim dblResult As Double If InStr(OutputField.Text, “+”) > 0 Then dblResult = Val(OutputField.Text.Left(Instr(OutputField.Text, _ ” + “))) + Val(OutputField.Text.Mid(Instr(OutputField.Text, _ “+”) + 2)) End If
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.