need help with VB6

Reply

Join Date: May 2009
Posts: 3
Reputation: ProgrammerX is an unknown quantity at this point 
Solved Threads: 0
ProgrammerX ProgrammerX is offline Offline
Newbie Poster

need help with VB6

 
0
  #1
May 5th, 2009
Hi
i have been working on a project for my younger brother. A simple VB6 and MS Access/SQL server based client-server database. For that i recently started working on VB6 as i previously had only worked on Java and C++. I have been consulting the book "Using Visual Basic 6" by Brian Siler and Jeff Spotts. Problem is embarassing enough in my first programe. When i try to compile it, it shows me an error "Compile error: Method or Data member not found". Program is very basic (Loan calculator) with four text fields, four labels(Principal, Annual Interest Rate, Term Year and Monthly payment) and two command buttons(Calculate Payment & Exit). I am sure that there is nothing wrong with the declaration or the syntax as it is absolutely according to the book still i am getting this error and i cant find anything about this error online or in the book. So i am stuck and need help.Can anyone please take a look into this. I would be much obliged.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdCalculate_Click()
  2. Dim cPrincipal As Currency
  3. Dim fIntRate As Single
  4. Dim nTerm As Integer
  5. Dim cPayment As Currency
  6.  
  7. cPrincipal = Val(txtPrincipal.Text)
  8.  
  9. fIntRate = Val(txtIntRate.Text) / 100
  10.  
  11. fIntRate = fIntRate / 12
  12.  
  13. nTerm = Val(txtTerm.Text) * 12
  14.  
  15. cPayment = cPrincipal * (fIntRate / (1 - (1 + fIntRate) ^ -nTerm))
  16. txtPayment.Text = Format(cPayment, “Fixed”)
  17. End Sub
  18.  
  19. Private Sub cmdExit_Click()
  20. End
  21.  
  22. End Sub
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: Norville is an unknown quantity at this point 
Solved Threads: 0
Norville Norville is offline Offline
Newbie Poster

Re: need help with VB6

 
0
  #2
May 5th, 2009
Check that you spelt the control name exactly the same in the code and the properties
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 807
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 147
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: need help with VB6

 
0
  #3
May 5th, 2009
At the top of the code window, above all other code, do you see the words "Option Explicit"? If not, add these words and press F8. Your error, when you compile, should now be highlighted. Now, in the future so that this appears automatically, goto VB's menu Tools>Options and when the dialog appears, place a check next to where it says "Require Variable Declaration". Click OK.

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 3
Reputation: ProgrammerX is an unknown quantity at this point 
Solved Threads: 0
ProgrammerX ProgrammerX is offline Offline
Newbie Poster

Re: need help with VB6

 
0
  #4
May 6th, 2009
Originally Posted by vb5prgrmr View Post
At the top of the code window, above all other code, do you see the words "Option Explicit"? If not, add these words and press F8. Your error, when you compile, should now be highlighted. Now, in the future so that this appears automatically, goto VB's menu Tools>Options and when the dialog appears, place a check next to where it says "Require Variable Declaration". Click OK.

Good Luck
Hi again,
Sorry for the delayed reply. The problem is still there. Though i have checked that Tools>Options>"Require Variable Declaration" still the problem remains the same. When i compile it same error comes up. i am attaching a printscreen of what it highlights when i break the compiling procedure, probably then you can see the problem. Thanks for your help and time. I really appreciate it.
X.
Attached Thumbnails
VBerror.jpg  
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 3
Reputation: ProgrammerX is an unknown quantity at this point 
Solved Threads: 0
ProgrammerX ProgrammerX is offline Offline
Newbie Poster

Re: need help with VB6

 
0
  #5
May 6th, 2009
Originally Posted by Norville View Post
Check that you spelt the control name exactly the same in the code and the properties
Hi
I have double checked the controls again but same problem again.. Dont know what to do. Thanks for your help and time.


X
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 807
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 147
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: need help with VB6

 
0
  #6
May 7th, 2009
First, if Option Explicit is not at the top of the code window, type it in.
Second, delete the .text and type in the dot (.). If textPrincipal is an actual control you should see the list of properties come up.

Now, it could be that you may have accidently renamed the control or perhaps misspelled the controls name in code so here is what I want you to do...

Go to the form view and select the textbox in question. Look in the properties window at the name property.

If it looks like the correct name then go back to the code window and remove everything after the open paren of the val function (val(....). Type in textp and hold down the CTRL key and press the space bar. Your textbox name should appear in the drop down list and if so just hit the tab key. Then type in the dot (.) and text should appear in the list BUT if you see caption then you have a label named as a text box.

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: need help with VB6

 
0
  #7
May 7th, 2009
Hi,

What I guess, is txtPrincipal has been created as a Part of the Control Array.
If so, you will find some Numeric value in the "Index" property. Just Clear that, your code should work fine. Also Check the same for other controls as well..

Regards
Veena
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC