Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why does not this program work?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I just tried a program from ACCESS 2000 VBA HANDBOOK. Unfortunately it does not work. I would like to know the reason.

Your help is appreciated.

Haijun

Option Compare Database
Option Explicit

Public Sub Division()
Dim dblnum As Double, dblden As Double, dblResult As Double
Dim strAnswer As String
On Error GoTo Err_Division
dblnum = InputBox("Enter the numerator.")
Err_Denominator:
dblden = InputBox("Enter the denominator")
dblResult = dblnum / dblden
MsgBox "The quotient is " & dblResult

Exit_Division:
Exit Sub

Err_Division:
Select Case Err.Number
Case 13
strAnswer = MsgBox("You must enter a number. Do you want to try again?", vbYesNo)
If strAnswer = vbYes Then Resume
Case 11
strAnswer = MsgBox("You must enter a non-zero number. Do you want to try again?", vbYesNo)
If strAnswer = vbYes Then Err_Denominator:
Case Else
MsgBox "Error number: " & Err.Number & " - " & Err.Description
End Select
Resume Exit_Division
End Sub

 
Should be:

If strAnswer = vbYes Then GoTo Err_Denominator:

Not
If strAnswer = vbYes Then Err_Denominator:

Err_Demonitor is an error label not a subroutine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top