🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #2827

Re: Divisione per zero

#2827
From: alberto
Date: Thu, 30 Jan 2003 23:30
47 lines
2105 bytes
Alan1 wrote:

> 29/01/03
> Ho creato un piccolo applicativo per mio uso, ma quando il programma esegue
> una divisione con un numero inferiore a 1
> mi da "Errore run-time '11': Divisione per zero"
> So che esiste una gestione degli errrori da scrivere nella routine del
> calcolo, ma non so come scriverla. Mi date una dritta per piacere?
> Grazie a tutti
> Alan1
> 
> 
> 
> 
> 
>
Private Sub divisione_sicura()
 
On Error GoTo gestione_errori 

'attivo la gestione degli errori
'seplicemente faccio saltare l'esecuzione
'alla etichetta gestione_errori

a = 1 / 0
'1/0 genera l'errore 11 (divisione per zero)

MsgBox "Ok possiamo continuare", vbInformation, "Et voila'"
'dopo aver avvisato dell'errore ricomincero' da questa riga

on error goto 0
'disattivo il gestore degli errori
'ora sono al sicuro

Exit Sub
'per saltare il gestore degli errori


gestione_errori:
    If Err.Number = 11 Then
 
        MsgBox "Attento, non si puo' dividere per zero!!",
vbInformation, "EHI!"
        Resume Next
'riprendo l'esecuzione dalla riga successiva a quella che ha generato
errore.
    End If
Technical Details
Message-ID: <5Ai_9.66416$ZE.1803284@twister2.libero.it>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!twister2.libero.it.POSTED!not-for-mail
References: <HURZ9.135768$AA2.5625338@news2.tin.it>

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII-7-bit
X-Google-Thread: f94ee,6d2af3dedcf3ae52
X-Google-Attributes: gidf94ee,public
X-Google-ArrivalTime: 2003-01-30 15:32:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!twister2.libero.it.POSTED!not-for-mail
From: alberto <c-appe@libero.it>
Newsgroups: free.it.visual-basic
Subject: Re: Divisione per zero
References: <HURZ9.135768$AA2.5625338@news2.tin.it>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 8bit
User-Agent: Noworyta News Reader/2.9
Lines: 47
Message-ID: <5Ai_9.66416$ZE.1803284@twister2.libero.it>
Date: Thu, 30 Jan 2003 23:30:09 GMT
NNTP-Posting-Host: 151.30.6.37
X-Complaints-To: abuse@libero.it
X-Trace: twister2.libero.it 1043969409 151.30.6.37 (Fri, 31 Jan 2003 00:30:09 MET)
NNTP-Posting-Date: Fri, 31 Jan 2003 00:30:09 MET
Organization: [Infostrada]