Anyone figured out if you can call a PUBLIC procedure in one form from an event or procedure in another form?
Taxes
Last edited by taxes; Dec 31st, 2003 at 04:09 AM.
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.
Using a Public dimension dose not help. I know it did in VB6 but it does not in VB.NET (unless you have adifferent version to me).
<- comment removed by admin - negative comments towards others not allowed - see Acceptable Usage Policy for forum ->
taxes.
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.
i think you'll find it does <comment removed by admin>. There is no need to answer to someone like that if they are trying to help you.....even if you do think they are wrong!!!!!!!!!! The only bit he got wrong was the private bit in front of the function should have been public. An easy typo and one that should be easy to understand <comment removed by admin>.
<comment removed by admin>and make sure your responses are accurate?
huh ? accurate ? He's trying to help and if he gave you the full working code , you're not going to pay him . So he helps , you should appreciate . That's what the forums meant to be .
Unless there is something wrong with my VB.NET 2003, ABX is wrong. You can ONLY, as far as I can see, refer from a form to a procedure in a module and not to one in another form, no matter what the declaration.
What annoys me is when someone treats me as an idiot without testing the problem and produces an "answer" without bothering to check if it is true.
I am sorry if my comments annoyed you but the entire tone of ABX's response was inaccurate, flippant and rude. All I did was to suggest he refrained from rude remarks. I was not criticising his technical knowledge.
Did you check the problem out before you responded?
The whole point of a technical forum is that we may share our practical experiences in programming matters. If I want to be insulted or used as a testing ground for puerile comedy there are many non technical boards available.
Re: nswan
May I have the extreme temerity to draw your attention to the slight possibility that I did realise ABX meant "Public" ?. Did you bother to read my response to ABX where I used the word "Public" in spite of his having used "Private"? May I also be allowed to ask if you have checked out the problem in VB.NET 2003? If I have less than 2 brain cells, how many have you got?
To ABX:
Please may I make it quite clear that my response was not directed at your answer but at your additional remarks, to which I took offence.
Regards,
taxes
Last edited by taxes; Dec 31st, 2003 at 09:28 AM.
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.
This thread needs to focus on the problem being presented and not on negative comments towards those trying to help -- whether their help is accurate or not.
Negative comments towards others -- whether they started them or not -- are a violation of this site's usage policy.
Thanks for focusing on the technical issues going forward.
Brad
Admin
Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
-------------------------------------------------------------
Brad! Jones
Lots of Software, LLC (I wrote: C Programming in One Hour a Day)(Dad Jokes Book)(Follow me on Twitter)
--------------------------------------------------------------
O.K. Point taken. I guess I over reacted. My apologies to any offended by my responses.
Taxes
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.
"If you don't have a FORMa instantiated, you must instance it before you call it:"
I have instantiated the form in a module. Also, the way I got round it (showing the form containing the code and referencing it in the activated event) proves that the form is available.
Have you actually tried this? If so, then I must re-install VB.NEt 2003.
Thanks,
taxes
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.
Ok, I i think you took my code wrong I meant this:
I Assumed you would understand that this was the form that was calling the function from "Form1" so this snippit is an example of how to call a function in "Form2". I am Sorry for any Confusion but you should really be more tolerant to mistakes as others have said, I AM NOT GETTING PAID, I am merely doing this out of my own free will and anthing I post may or may not work (if its something im not sure about it check in VS but this time i didnt think i had to and if i did you just mis-interpreted what I meant.
This should clear up what I mean't
VB Code:
'BELONGS IN "FORM1"
'Function that calls function
Private Function CallFunction()
Dim frm2 as New Form2
frm2.FunctionToCall
'....
VB Code:
'Belongs In "Form2"
Public Function FunctionToCall
'This is the Function That MUST be Public
Msgbox("HELLO")
End Function
Thanks Pirate, nemaroller, nswan
and taxes no hard fellings, i guess i wasnt thinking when i made the example (it seemed clear to me )
"If you don't have a FORMa instantiated, you must instance it before you call it:"
I have instantiated the form in a module. Also, the way I got round it (showing the form containing the code and referencing it in the activated event) proves that the form is available.
Have you actually tried this? If so, then I must re-install VB.NEt 2003.
Thanks,
taxes
What I mean is... if you added two forms to a project. And simply put messgebox.show(form2.text) in a button-click event in Form1, you would get a reference not instance of an object error.
If you declared the form2 in a module that runs at startup, and expose the form2 instance publicly in the module, then yes, you would not need to instantiate it again, because it is available globally (not recommended.), and the sample in the first paragraph would execute without fail.
Anyway, the question really is.. what is it about the code in form2 that you need to call from form1. If its code that may be needed at any time, you should stick it in a class of its own, so you don't waste resources by creating a whole form class, just to call a piece of code. But that's just me, my mindset... if its not related to UI events, and not particular to the form itself, stick it in its own class, then create the class when necessary.
I have spent the last hour trying out the various suggestions. I agree with your comments on using a message box to show the text of another form but that does not seem to relate to my problem.
"Anyway, the question really is.. what is it about the code in form2 that you need to call from form1. "
Form1 contains a datagrid which can be used by any one of six other forms, which will pass parameters to a procedure in Form1 determining the size of the datagrid and the records to be displayed therein, which then displays the datagrid. Whatever I do I cannot access that procedure from another form. (You can do this in VB6 by using something like Form1.proceed (assuming "proceed" is the name of the procedure required) but not in VB.NET).
As I have said, to get round it I have placed the required code in the Form1 activate event and used the code "frm1.ShowDialog" in the calling form event.
Is that any clearer?
Taxes
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.
This being my first venture into this Forum I was not aware that some of your remarks were part of a signature. I assumed they were personally directed at me.
Guess it's my misunderstanding. If my arm was long enough I'd reach out and say let's shake and start again.
taxes.
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.
As several of you just did not seem to be experiencing the problem I was having, re installing was the only option. Guess what? I can now, using the same project as before, reference the procedure from outside the form!!!
Thanks everyone and apologies for so much time consumed.
Regards,
Taxes.
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.
This being my first venture into this Forum I was not aware that some of your remarks were part of a signature. I assumed they were personally directed at me.
Guess it's my misunderstanding. If my arm was long enough I'd reach out and say let's shake and start again.
taxes.
I knew that some one would get offended by those one of these days, I made my signature a little more clearer so that hopefully that won't happen again.