If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Run-time error with VB6 calling a subroutine

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-11, 01:13
Ehwe Ehwe is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
Run-time error with VB6 calling a subroutine

I am new to VB6 and trying to create an application for my project using VB6. I am having 3 problems in the code during run-time:
1. If i press the calculate command button on my application i get a compile error: expected function or variable, when I call a sub procedure to another another sub procedure to input datas for numerical calculation.

2. It gives a second compile error: run-time error 6: Overflow with some of the equations (anodlife, totanodmass, maxgrdresist) as stated below

3. The third problem has to do with the link to the output form. If I press the calculate command button the output forms: frmcpcalculatedoutput, frmoffcalculatedoutput, will display :run-time error '91' : Object variable or with block variable not set. How can I link the output form to the mother form during compile time so that when I press the execute button on the child form it will cause the output to be displayed on the screen.

Below are snippets of the code. An urgent help will be appreciated. Thanks
'Gives me run-time error with the call subs. How do I get rid of it please
...
'Calculate sacrificial Anode mass
Sub sacranomass()
Call totcurreq
Dim totcurrequirement As Integer
totcurrequirement = totcurreq
Dim anodlife As Integer
Dim sacranomass As Integer
sacranomass = (anodlife * totcurrequirement) / (anodeweight * 49.3)
End Sub
Sub protareaanod()
Call totsurf
Call sacranomass
totalsurfacearea = totsurf
Dim protareaanod As Integer
protareaanod = totalsurfacearea / sacranomass
End Sub
....
'Gives me overflow problems. I declared my variables with integer. I tried long but won't end the over flow problem. When do I use Double to declare a numeric data type considering an output less than zero

'Calculation of anode life anodlife
Dim anodlife As Integer
anodlife = (anodeweight * energycapabilty * anoutizatfact) / (8760 * anoutputcurrent)

'Calculation of anode mass
Dim totanodmass As Integer
Dim totcurreq As Integer
Dim totcurrequirement As Integer
'Call totcurreq
totcurrequirement = totcurreq
totanodmass = (anodlife * totcurrequirement) / (anodeweight * 1000)

Dim maxgrdresist As Integer
maxgrdresist = (roh * anodeshapefactor) / ((anoquant) * anodelength) + (roh * parallelingfactor) / (anodespacing)

Thanks guys for helping out.
Reply With Quote
  #2 (permalink)  
Old 07-22-11, 09:39
Shayan Shayan is offline
Registered User
 
Join Date: Jul 2011
Location: Bandar Abbas - Iran
Posts: 9
Hi

You can not assign a value to a Subroutine !!!
Define them as Function like : Private Function ABC As Integer

You are calling routine B in routine A and calling routine A in B !!!! that is why you are getting overflow

Why your code is like that ?? i think it it basically wrong , what you wanna do ??

tell me , all will write it for you
Reply With Quote
  #3 (permalink)  
Old 07-22-11, 23:03
Ehwe Ehwe is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
Run-time error with VB6 calling a subroutine

Got that figured out already mate. You can imagine how my code looks now.
Reply With Quote
  #4 (permalink)  
Old 07-22-11, 23:08
Ehwe Ehwe is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
Run-time error with VB6 calling a subroutine

The overflow problem was not actually due to the calling. It was due to the fact that some of the variables used in the equation were not assigned values and because i was using a sub instead of a function which would have assigned values were i needed them. So there is nothing wrong calling functions into other functions to return values for calculations.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On