LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-17-2004, 12:02 PM   #1
ashirazi
Member
 
Registered: Jul 2004
Posts: 60

Rep: Reputation: 15
VB simple stuff...


Hey,

I'm not an expert in VB but can someone tell me what does the second line do?
Code:
 On Error Resume Next
I would also like to know about the built in error checking i.e. what does Err5 and Err6 checks for.


Code:
For i = 1 To smodules 
On Error Resume Next
kl(i, 1) = ks(i, 1) * Exp(-(-p(i, 0) / b(i, 1)) ^ cc(i, 1)) 
ku(i, 1) = ks(i, 1) * Exp(-(-p(i, 1) / b(i, 1)) ^ cc(i, 1)) 'weibull function for upper half of element i
If Err = 5 Then
    nodefailure = i
    nodetype = "lateral shoot"
    Exit Do
End If
nn = (-p(i, 1) / b(i, 1)) ^ cc(i, 1) 'n value for upper half in preparation for pgamma function
aa = 1 / cc(i, 1) 'assigns a value for incomplete gamma function
pgamma aa, nn 'calls function pgamma
If Err = 6 Then
    nodefailure = i
    nodetype = "lateral shoot"
    Exit Do
End If
phiu = (1 - gammp) * gamma * ks(i, 1) * b(i, 1) / cc(i, 1) 'phi for upper half
nn = (-p(i, 0) / b(i, 1)) ^ cc(i, 1) 'n value for lower half
pgamma aa, nn 'calls pgamma again with lower half n value
If Err = 6 Then
    nodefailure = i
    nodetype = "lateral shoot"
    Exit Do
End If
phil = (1 - gammp) * gamma * ks(i, 1) * b(i, 1) / cc(i, 1) 'phi for lower half
jl(i, 1) = cf(i, 1) * (phil - phiu) 'flux of element i--CF converts conductivity to conductance
Next i

Thanks
raven
 
Old 10-17-2004, 12:04 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
on error resume next is VB's abissmal attempt at fault recovery. if it hits somesthing that doesn't make sense, either runtime logic, e.g. object doesn't exist... or base syntax errors.

what you do after that is your problem. it never stops making me laugh how pathetic that directive really is.
 
Old 10-17-2004, 12:11 PM   #3
ashirazi
Member
 
Registered: Jul 2004
Posts: 60

Original Poster
Rep: Reputation: 15
How about those other error checks, like if Err=5.... stuff. What are those if statements looking for?
 
Old 10-20-2004, 12:50 PM   #4
zchoyt
Member
 
Registered: Feb 2003
Location: Boise ID
Distribution: fedora
Posts: 156

Rep: Reputation: 30
if err = 5
is VB's way of checking the err.number against error code 5. Who ever wrote this code used 5 as a "magic number" .


The other way to handle errors in vb is
on error goto tag

so you would have something like:
Code:
public sub My sub
    on error goto tag

    'body of sub

    exit sub

    tag:
    if err.number=4 then
        'action
    elseif err.number-5
        'action
    end if

end sub

This doesn't apply to vbscript. vbscript only has on error resume next.

Check vbforums for more info on VB code.

Hope this helps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
When installing new stuff in suse 9.1, do you uninstall old stuff first? randon SUSE / openSUSE 1 12-25-2004 04:37 PM
problems creating a simple bootable cd to perform a simple task czarherr Linux - Software 1 11-11-2004 05:22 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
Just an example of what a pain simple stuff in linux can be Edward78 Linux - General 17 05-03-2003 03:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration