- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: Simple?? VB.net question
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Simple?? VB.net question"
Collapse
-
That works although same problem with my original code. I was thinking that the inaccessibility error was a general problem in not being able to access the form, in fact it was just a specific function of that form that is protected. Don't need to use it anyway (it was just an example I copied off an MS page) so problem sorted. Ta chaps!Last edited by xoggoth; 29 May 2007, 08:37.
-
Bored so:-
as buffdaddy says you should probably be passing it by value unless you are tring to return a different form than the one passed in - which migh be unhelpful
Anyway this is fine:-
Module Module1
Public Sub EnableDoubleBuffering(ByRef frm As System.Windows.Forms.Form)
frm.Text = "QQQQ"
End Sub
End Module
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Module1.EnableDoubleBuffering(Me)
Dim a As New Form2
'Has to be a type of Form because it will foul up due to narrowing if not.
Dim b As Form
b = a
a.AA(b)
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Friend Sub AA(ByRef frm As System.Windows.Forms.Form)
Module1.EnableDoubleBuffering(Me)
Module1.EnableDoubleBuffering(frm)
End Sub
End Class
Whether it is sensible or any help is a different matter of course.
Leave a comment:
-
not sure why you are passing the Form in by ref. It should work without the ref since the Form is a Reference Type
http://msdn2.microsoft.com/en-us/lib...s2(VS.80).aspx
i tried this quickly (in c# winforms), and it works
Leave a comment:
-
Simple?? VB.net question
Got a useful answer last time, so worth a try.
I just want to stick all the common functions called from different forms in one place rather than duplicate code, and for some I need to pass forms by reference to those functions. But if I have something like:-
Public Sub EnableDoubleBuffering(ByRef frm As System.Windows.Forms.Form)
in a public module or class, any reference to frm gives 'not accessible in this context because it is protected'.
The solutions I have looked at on the net all seem to to be along the lines of declaring a new instance of, or inheriting from, a specific form class, however:-
a) frm does not necessarily always refer to the same form class
b) frm could refer to different instances of the same form class
I can think of a rather messy solution to a) but not sure how to handle b). Ta for any answers.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Contractors, don’t be fooled by HMRC Spotlight 67 on MSCs Yesterday 09:20
- HMRC warns IT consultants and others of 12 ‘payroll entities’ Dec 3 09:15
- How you think you look on LinkedIn vs what recruiters see Dec 2 09:00
- Reports of umbrella companies’ death are greatly exaggerated Nov 28 10:11
- A new hiring fraud hinges on a limited company, a passport and ‘Ade’ Nov 27 09:21
- Is an unpaid umbrella company required to pay contractors? Nov 26 09:28
- The truth of umbrella company regulation is being misconstrued Nov 25 09:23
- Labour’s plan to regulate umbrella companies: a closer look Nov 21 09:24
- When HMRC misses an FTT deadline but still wins another CJRS case Nov 20 09:20
- How 15% employer NICs will sting the umbrella company market Nov 19 09:16
Leave a comment: