Results 1 to 3 of 3

Thread: run-time error handlers...

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    8

    Post

    Hey Guys...I need to get some info about error handlers. I need to write error handler that focuses on invalid numeric values, numeric overflow or underflow, and putting text chars as opposed to number values...any suggestions?

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Post

    Could you be a little more specific in how you are adding this information to your database? Like are you using a textbox, data combo box, etc.?

    For me the easiest way to control the data input is to use either a data combo box populated with information from another table (e.g. for the field "STATE" I would have a DBCombo linked to a table with a list of states) or to use the KeyPress routine in a text box. Example: a text box where you only want the user to input numeric data to a maximum of 10 digits looks like this:

    Private Sub txtCode_KeyPress (KeyAscii As Integer)

    If KeyAscii < Asc("0") Or KeyAscii > Asc ("9") Then
    KeyAscii = 0
    End If

    If Len(txtCode.text) = 10 and KeyAscii <> vbKeyBack Then
    KeyAscii = 0
    End if

    Exit sub


  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    8

    Post

    Here is the code that I want to use the ascii for:
    Private Sub cmdEvaluate_Click()
    On Error GoTo error_handler
    If mnuPayment.Checked = True Then
    txtPayment = FormatCurrency(Pmt(CDbl(txtInterestRate), _
    CDbl(txtPeriods), CDbl(txtPresentValue), (txtFutureValue), 0), 2)
    ElseIf mnuPresentValue.Checked = True Then
    txtPresentValue = FormatCurrency(PV(CDbl(txtInterestRate), _
    CDbl(txtPeriods), CDbl(txtPayment), (txtFutureValue), 0), 2)
    ElseIf mnuFutureValue.Checked = True Then
    txtFutureValue = FormatCurrency(FV(CDbl(txtInterestRate), _
    CDbl(txtPeriods), CDbl(txtPayment), (txtPresentValue), 0), 2)
    Else
    MsgBox "Must check Calculation option"
    End If
    Exit Sub
    error_handler:
    MsgBox "Cannot Calculate using the given values", vbCritical
    End Sub

    My questions is: Can I put the ascii routine within this private sub or do I need to make its own sub (Reason Why I ask is that I got the Error handler within it...I want to keep it within one area)?

    Thanxs for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width