473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

"method or data member not found" using Toolbar button

23
I am not an experienced programmer. I am getting an error as "method or data member not found" when i entered the following code in buttonclick procedure of the toolbar.

Expand|Select|Wrap|Line Numbers
  1. select case button.key
  2. case "btn1"
  3.        msgbox ""
  4. case "btn2"
  5.       msgbox ""
  6. end
  7. end select
Can anybody help me in figuring out this problem

Thanks
Mar 27 '07 #1
22 7134
SammyB
807 Expert 512MB
I am not an experienced programmer. I am getting an error as "method or data member not found" when i entered the following code in buttonclick procedure of the toolbar.

select case button.key
case "btn1"
msgbox ""
case "btn2"
msgbox ""
end
end select

Can anybody help me in figuring out this problem

Thanks
Kay, your Case statement is not setup correctly: remove the line "end". Also, I think that it does not like button.key. What did you Dim button as? What version of VB are you using: VBA, VB6, or VB.NET?
Mar 27 '07 #2
kkk1979
23
Kay, your Case statement is not setup correctly: remove the line "end". Also, I think that it does not like button.key. What did you Dim button as? What version of VB are you using: VBA, VB6, or VB.NET?
I declared button as Integer, also I removed the end statement. Still I am getting the same error. I am using vb98.
Mar 27 '07 #3
SammyB
807 Expert 512MB
>I removed the end statement
Great!

>I am using vb98
Why? We can give you general ideas, but I and most others have never seen vb98

>I declared button as Integer
then you cannot have button.key
so what does button equal at the top of your code. Can't you just do
Expand|Select|Wrap|Line Numbers
  1.         Select Case button
  2.             Case 1
  3.                 MsgBox("First")
  4.             Case 2
  5.                 MsgBox("Second")
  6.             Case Else
  7.                 MsgBox("Something else")
  8.         End Select
Mar 27 '07 #4
kkk1979
23
I am using vb6.0 version. I tried by removing ".key" as you told. This is not showing anything.
Mar 27 '07 #5
SammyB
807 Expert 512MB
I am using vb6.0 version. I tried by removing ".key" as you told. This is not showing anything.
Ah, VB6, where is the wipes off the sweat smilie.
You are correct, it should be Button.Key. So,
  1. Make sure that you added buttons to the ToolBar
  2. Make sure that you entered the keys for the buttons: btn1, btn2
Now, you event routine should look like:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  3.     Select Case Button.Key
  4.         Case "btn1"
  5.             MsgBox "First"
  6.         Case "btn2"
  7.             MsgBox "Second"
  8.     End Select
  9. End Sub
Mar 27 '07 #6
kkk1979
23
I have been trying this from yesterday. I kept the .key as btn1 and btn2 correctly.
getting the same compilation error by highlighting ".key" method in blue color.
I am sorry to tell like this.
Mar 27 '07 #7
SammyB
807 Expert 512MB
I have been trying this from yesterday. I kept the .key as btn1 and btn2 correctly.
getting the same compilation error by highlighting ".key" method in blue color.
I am sorry to tell like this.
Don't be sorry, this is why we get the big bucks! ;) In #3, you said "I declared button as Integer". VB defines it as MSComctlLib.Button. Does your code look exactly like mine?
Mar 27 '07 #8
kkk1979
23
Yes, have been trying the code which is exactly like yours. But as you asked me about the declaration, then I thought "ok, I need to declare" like that.
So I tried both ways. I think my code doesn't like .key method.(but why I don't know)
Mar 27 '07 #9
SammyB
807 Expert 512MB
Yes, have been trying the code which is exactly like yours. But as you asked me about the declaration, then I thought "ok, I need to declare" like that.
So I tried both ways. I think my code doesn't like .key method.(but why I don't know)
I would suggest that you start all over again, slowly. Follow these steps:
  1. Get out of all windows but this one and start VB6 from the Start button
  2. In the New Project dialog, select Standard EXE and press Open
  3. If you don't have a Toolbar control in the toolbox, press Ctrl T and place a checkmark before Microsoft Windows Common Controls 6.0
  4. Double-click the toolbar icon in the toolbox to add it to your form
  5. Click on Custom in the Properties window and press the elipses button.
  6. Click on the Buttons tab and click Insert Button.
  7. Make the caption 1 and the key btn1
  8. Click Insert Button again
  9. Make the caption 2 and the key btn2 and press OK
  10. Double-click on the toolbar to bring up the code window
  11. Add code to the Click event
Expand|Select|Wrap|Line Numbers
  1. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  2.     Select Case Button.Key
  3.         Case "btn1"
  4.             MsgBox "First"
  5.         Case "btn2"
  6.             MsgBox "Second"
  7.     End Select
  8. End Sub
Now, press the Start button and see if the buttons work.
Mar 27 '07 #10
I could be wrong, but I think that the Member .key has to belong to the class Button... Hope this helps, Roger
Mar 27 '07 #11
kkk1979
23
I followed the steps,got the same error.But when i double clicked the toolbar from the toolbox(as in step 4), I got toolbar wizard along with toolbar.Does this makes any difference ?? Waiting for your reply !!!!
Mar 27 '07 #12
kkk1979
23
That might be the reason, How do I check that ?
I opened Object Browser, selected "button" option in left pane, nothing is shown in the right pane.
If that is your guess, can you please show how to include the ".key" method to my project.
Mar 27 '07 #13
SammyB
807 Expert 512MB
I followed the steps,got the same error.But when i double clicked the toolbar from the toolbox(as in step 4), I got toolbar wizard along with toolbar.Does this makes any difference ?? Waiting for your reply !!!!
What is a toolbar wizard? We are not using the same VB6. Remove your toolbar and press Ctrl T to open the Components dialog. Uncheck everything on the Controls tab and press OK. Now, press Ctrl T again and place a checkmark before Microsoft Windows Common Controls 6.0.

Now, try adding the Toolbar again. If you get a wizard, some other VB6 guru will have to help you because I don't do wizards, daemons, or databases. :D Hope this solves it! --Sam
Mar 27 '07 #14
kkk1979
23
How do I check whether all the required members of button are present in my project ??
Mar 27 '07 #15
SammyB
807 Expert 512MB
How do I check whether all the required members of button are present in my project ??
:confused: Since you are using a non-standard toolbar, we have no way of knowing. Please do what my last post said.
Mar 27 '07 #16
kkk1979
23
Thank you for your help.That is the reason. But how can I include the members to the button ?
Mar 27 '07 #17
kkk1979
23
I looked for the methods of button object in Object Browser, then compared with other system's Button Object. So I found that my system has no methods for button object. Is it possible to add the methods to my system too ? Can you please check it
Thank you very much for your help
Mar 27 '07 #18
I think in object oriented programming such as Visual Basic .Net you can add your own custom methods to the Button Class. That is all I remember... Roger
Mar 27 '07 #19
Killer42
8,435 Expert 8TB
I am not an experienced programmer. I am getting an error as "method or data member not found" when i entered the following code in buttonclick procedure of the toolbar.

Expand|Select|Wrap|Line Numbers
  1. select case button.key
  2. case "btn1"
  3.        msgbox ""
  4. case "btn2"
  5.       msgbox ""
  6. end
  7. end select
Can anybody help me in figuring out this problem
Sorry, I haven't followed the rest of the thread yet (short of time) but if you have defined button as anything, that is probably your problem. If this is the type of toolbar I'm familiar with, Button should represent the parameter (ByVal Button As MSComctlLib.Button) which is received when this event procedure is called.
Mar 28 '07 #20
Killer42
8,435 Expert 8TB
Oops! Looks as though I spoke too soon.

Are you sure you don't have some custom object you're created (or a form or whatever) called "Button"?

Here's an exercise which might (or might not) help. Change the name of the parameter to something which you know won't match anything else. For example...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Toolbar1_ButtonClick(ByVal KillerSaidToDoThis As MSComctlLib.Button)
  2.    Debug.Print KillerSaidToDoThis.Index, KillerSaidToDoThis.Caption, _
  3.                KillerSaidToDoThis.Key
  4. End Sub
Mar 28 '07 #21
kenobewan
4,871 Expert 4TB
I believe that we are reaching the end of how much help we can provide here. Clear step by step instructions have been given.

We all started somewhere and there is no shame in being a newbie. My suggestion is find a book or course and learn the basics. This is a site for programmers and not geared to learning the basics - it is assumed by the experts that you have this.

So please learn the fundamentals, it will save you time in the log run. I am sure we could suggest some resources if you like. Thanks.
Mar 28 '07 #22
Killer42
8,435 Expert 8TB
I looked for the methods of button object in Object Browser, then compared with other system's Button Object. So I found that my system has no methods for button object.
When you select Button in the object browser, what does it show in the grey window down the bottom?

(Note, I've updated the title of the thread - "Hi All" won't help anyone in the future who needs to search for help on this topic).
Mar 28 '07 #23

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Poseidon | last post by:
I use "read" method to read some blocks into a buffer from a filestream, and send data in the buffer to remote server with "send" method of cocket class. For certain computers, I have to add "sleep"...
3
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup...
2
by: Tom S | last post by:
I'm using ASP.NET with C# as my code behind and I figure out how to get the above process to work. I've found many examples online for using the 'method' member to "POST", but none for setting it...
2
by: martyn_wynne | last post by:
Hi, I have found a odd one, my submit button is not submitting on a method="get" form after using any form of DataBind? Has anyone struck this problem before? here is snipits of the code as...
0
by: Owen | last post by:
Hello everyone, I am using VS.NET 2003(Trandition Chinese) Edition, and httpLook software for checking http requests. I found a problem that the following programs don't really "POST". These...
0
by: Jerry Boone | last post by:
I did a lot of searching and found many who said this couldn't be done. After searching I didn't "seem" to turn up anyone who provides this solution. If you posted or found something on this...
6
by: James MA | last post by:
I'm now writing a small program to communicate a web server to simulate a web client. I use te httpwebrequest to talk with the server, and it works find for "POST" method, however, when i test...
2
by: johkar | last post by:
Why does if(win==null || win.closed) return true after one PDF is open. Something very wierd going on with IE 6. I also get a member not found error if a child window is already open. This script...
11
by: sofeng | last post by:
I'm not sure if "data hiding" is the correct term, but I'm trying to emulate this object-oriented technique. I know C++ probably provides much more than my example, but I'd just like some feedback...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.