|
-
Jun 16th, 2000, 05:24 AM
#1
I'm trudging along, learning VB as I go, and am designing a sample program as I read through a VB manual.
My program is basically a "calculator" for computing response rates, gross sales, overhead costs, etc., for Direct Marketing people.
I have placed an ErrorCheck within a Module to be called from the form.
Code:
'Error-Checking
If ErrorCheck() = 1 Then
Exit Sub
End If
In the module I have written:
Code:
Public Function ErrorCheck() As Integer
Dim IntPress As Single
'Error-checking for Gross Sales.
If Val(frmQuick.txtPrice.Text) <= 0 Then
IntPress = MsgBox("Enter a value for the price", vbExclamation, "Gross Sales")
frmQuick.txtPrice.SetFocus
ErrorCheck = 1
Exit Function
End If
If Val(frmQuick.txtSold.Text) <= 0 Then
IntPress = MsgBox("Enter number of units sold", vbExclamation, "Gross Sales")
frmQuick.txtSold.SetFocus
ErrorCheck = 1
Exit Function
End If
'No error occurred if execution gets here
ErrorCheck = 0
End Function
When the field is blank, the MsgBox and set focus works fine. When the field begins with an alpha character (in case of an inadvertent entry error), then a number, it works fine.
But when I enter a numeral followed by an alpha character I recieve a Runtime Error '13', Type Mismatch. 
Where have I missed this??? Obviously some code checking for Alpha Characters???
Thanks for any assistance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|