|
-
Feb 13th, 2004, 10:44 AM
#1
Thread Starter
Frenzied Member
referencing an object that's on another form [RESOLVED]
I am writing a function that has arguments passed to it....no problem. But, I need determine the checkstate of a checkbox that does not get passed to it.
I have this code and it says: Reference to a non-shared member requires an object reference.
VB Code:
Public Function FormatPhoneNumber(ByVal PhoneNumber As String) As String
Dim three As String
Dim four As String
three = Left(PhoneNumber, 3)
four = Mid(PhoneNumber, 4)
If [COLOR=red]fclsTicketingMain.tabMainControl.tabTrbTick.chk423.checkstate[/COLOR] = True Then
PhoneNumber = "(423)" & " " & three & "-" & "four"
Else
PhoneNumber = "(706)" & " " & three & "-" & "four"
End If
End Function
what has to be done to be able to use the state of the check box
Last edited by Andy; Mar 25th, 2004 at 10:17 PM.
-
Feb 13th, 2004, 01:02 PM
#2
PowerPoster
Hi,
I've tried your code but could not identify the object property "tabTrbTick" in your line:
If fclsTicketingMain.tabMainControl.tabTrbTick.chk423.checkstate = True Then
So I replaced it with
If form11.CheckBox1.CheckState = True Then
and it works perfectly.
So, from your entire code can you identify the difference?
Last edited by taxes; Feb 13th, 2004 at 02:13 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 13th, 2004, 09:40 PM
#3
Thread Starter
Frenzied Member
i'm putting too much into it. I need only to use the form.control.property. that's PART of the problem.
I still get that error though. Apparantley, I'm not referencing it correctly. The blue syntax lines go away but upon debugging, I get that error.
Any suggestions?
-
Feb 14th, 2004, 09:41 AM
#4
PowerPoster
Hi,
Try doing what I did in my previous post. If that works, then your problem is in the difference.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 14th, 2004, 04:02 PM
#5
PowerPoster
Hi,
I just cannot figure out what the following is
tabMainControl.tabTrbTick.chk423.checkstate
The only reference I can find in MSDN to a checkstate property is in a checkbox.
neither is there any reference to .tabTrbTick. in a Tab Control.
Have you constructed your own class here?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 14th, 2004, 04:12 PM
#6
tabTrbTick is probably the name of the tabpage in the tabcontrol.
tabMainControl.tabTrbTick.chk423.checkstate
[TabControl].[TabPage].[CheckBox].CheckState
I'm curious why you say you can just refer to the form by name taxes. I noticed you mentioned that on a previouspost as well. Are you converting this forms from VB6? Did you declare them as the same name as the type and in some higher scope?
-
Feb 14th, 2004, 07:08 PM
#7
Frenzied Member
Are you referring to the form by the name you've given it in the Solution Explorer? That won't work.
I know I had a similar question a few weeks ago, but for crying out loud, this question's been discussed every other day for the past couple weeks, at least.
Please, try searching the forum first.
None of the above applies to my questions, of course
Edneiss & Pirate for mods! Whatever happened to that?
-
Feb 14th, 2004, 07:38 PM
#8
PowerPoster
Hi Edneeis
"I'm curious why you say you can just refer to the form by name taxes. I noticed you mentioned that on a previouspost as well. Are you converting this forms from VB6? Did you declare them as the same name as the type and in some higher scope?"
1. No. I never try converting anything from VB6. I think that is counterproductive. I want to learn and stick to VB.NET.
2. When I see a problem posted, I try to replicate it and the experiment with it - this way I improve my debugging experience. What I did in this case was to create fclsForm1 and declare a public instance of it in a module naming it form11, because I was using an existing project I use for such testing, i.e. for my personal convenience.
Hi Salvelinus,
"Are you referring to the form by the name you've given it in the Solution Explorer? That won't work."
See my above response.
"I know I had a similar question a few weeks ago, but for crying out loud, this question's been discussed every other day for the past couple weeks, at least."
I realise that, but this is not the point I am trying to make with regard to the Phantom's original problem. It is only a side issue which needs clarifying. All I am trying to convey to him is that, apart from the identity of the tabControl or whatever (which I have not yet used so am not immediately familiar with), the code he listed works, provided the variable declarations are correct. Therefore, his problem must lie with the code line referring to the tabControl which, looking at his postings, he will be able to sort out and I can learn from that.
As I am a relative newcomer, please educate me to the meaning of
"Edneiss & Pirate for mods! Whatever happened to that?"
Regards,
Last edited by taxes; Feb 14th, 2004 at 07:41 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 14th, 2004, 09:23 PM
#9
Thread Starter
Frenzied Member
As I am a relative newcomer, please educate me to the meaning of
"Edneiss & Pirate for mods! Whatever happened to that?"
He's saying that people are posting the same questions over and over and that ed and pirate should be moderators to erase the extra posts.
I agree with the theory that double-posts shouldn't be allowed but, sometimes you can't find a thread if you don't exaclty know what it is you're looking for.
If it's been discussed every other day, then I was out those days.
-
Feb 15th, 2004, 12:20 AM
#10
Hey taxes, ok I see now. Its' because you have a public instance in a module that it works. I wasn't trying to pick on your or say anything bad, by-the-way, I was just curious. The reason I brought up converting a VB6 form is because when it converts them to .NET it adds a DefInstance property and makes a shared instance of the form (so it behaves like a VB6 form). So I thought you might have done that but now I see it's that you put an instance in the module.
This question does get asked a lot because I think the topic of instancing doesn't get enough attention or may be difficult to get the hang of at first.
Why is it that the checkbox is not passed into the function? Or why is the function not on the form instance containing the checkbox not the place where the function is called from?
Now I personally think the coolest thing about programming is the fact that there are many ways to do the samething. This leaves a lot of room for style, but it generally will help to follow some of the common rules/suggestions/standards. Not to say you are wrong in any way if you don't.
Last edited by Edneeis; Feb 15th, 2004 at 12:26 AM.
-
Feb 15th, 2004, 09:37 AM
#11
Frenzied Member
Towards the end of last year there was a thread that VBForums might be looking for new moderators on the forums, and Edneiss & Pirate were mentioned as candidates for this one.
In the past couple weeks, at least, I've seen this same question or variations of it almost every day, basically, how do you refer to/show another form or its controls? Maybe there could be a FAQ link posted at the top of the forum.
-
Feb 15th, 2004, 09:49 AM
#12
Thread Starter
Frenzied Member
I think I'll try to pass along the checkbox's checkstate to the function. That's the problem I'm having for the most part. I don't really like to have my function/sub's on the startup form but I may have to do that at one point.
-
Feb 15th, 2004, 10:42 AM
#13
PowerPoster
Hi Edneeis,
No offfence taken, sorry if my language gave that impression, don,t forget I'm a Limey and tend to use formal language as a matter of course.
Phantom,
"I think I'll try to pass along the checkbox's checkstate to the function. That's the problem I'm having for the most part. I don't really like to have my function/sub's on the startup form but I may have to do that at one point."
I think you should try to solve your existing problem, not get round it, otherwise it will come back to haunt you someday. Remember the Alamo!! Santa Anna HAD to get rid of the Alamo because if he just bypassed it - which he could have done - it would have been a constant danger to his supply route, so he lost thousands of his men in taking it out. (I know it did not do him much good in the end, but the principle is there)
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|