What am I missing??? When I run the code without the If Then statements to check for valid field entries... The equation is fine.
When I drop in the If Then statements, the code will return the message box. Once the Okay button is selected instead of setting focus on the offending text box (If an entry wasn't made and the box is empty) I get a 'Runtime Error 13'. With the curPrice = txtPrice.Text highlighted once I try to Debug it.
I used the MSDN Library to look it up and it tells me something about variables not being equal.
Here is the code... Could someone shed light where I have run off the trail???
Thanks...Code:Private Sub cmdCompute_Click() 'Use calculation to determine 'total sales. ' 'curPrice is the price of product. 'intSold is number of units sold. 'curTotal is the gross sales amount. Dim curPrice As Currency, curTotal As Currency Dim intSold As Integer, intPress As Integer 'check for valid entry in Price field If Val(txtPrice.Text) <= 0 Then IntPress = MsgBox("Invalid Price. Please enter Price.", vbExclamation, "Price Request") txtPrice.SetFocus End If 'Check for valid entry in Sold field If Val(txtSold.Text) <= 0 Then IntPress = MsgBox("Please enter number of units sold.", vbExclamation, "Units Sold") txtSold.SetFocus End If curPrice = txtPrice.Text intSold = txtSold.Text txtTotal.Text = Format(curPrice * intSold, "Currency") 'Calculate gross sales. End Sub![]()




Reply With Quote