943,704 Members | Top Members by Rank

Ad:
May 5th, 2009
0

need help with VB6

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ProgrammerX is offline Offline
3 posts
since May 2009
May 5th, 2009
0

Re: need help with VB6

Check that you spelt the control name exactly the same in the code and the properties
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Norville is offline Offline
2 posts
since May 2009
May 5th, 2009
0

Re: need help with VB6

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
May 6th, 2009
0

Re: need help with VB6

Click to Expand / Collapse  Quote originally posted by vb5prgrmr ...
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
Click image for larger version

Name:	VBerror.jpg
Views:	11
Size:	113.8 KB
ID:	10066  
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ProgrammerX is offline Offline
3 posts
since May 2009
May 6th, 2009
0

Re: need help with VB6

Click to Expand / Collapse  Quote originally posted by Norville ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ProgrammerX is offline Offline
3 posts
since May 2009
May 7th, 2009
0

Re: need help with VB6

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
May 7th, 2009
0

Re: need help with VB6

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
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: SQL problem - simple?
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Uninstallation Problems with my Package in Visual Basic





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC