Change A Forms Access Modifier To Public?
Jun 11, 2010i want to now how to change the access modifier of a form so that it is publiv ind=stead of friend.
View 2 Repliesi want to now how to change the access modifier of a form so that it is publiv ind=stead of friend.
View 2 RepliesWhen I develop a Windows Forms app in Visual Studio using C#, every control that I add to my form is by default marked as private, which is what I want.
When using VB.NET, every control is by default marked as Friend (the equivalent of internal in C#), which is not what I want.
Can I just change this default? It seems like surely it's a setting somewhere.
My problem is that I have made a Tabbed WebBrowser in VB 10 I have a TabControl1 and the following code as webbrowser
CType(TabControl1.SelectedTab.Item(0),WebBrowser)
I want to control the browser from another form but it is Private and I need ti set it to public.
[code].....
Can a function or sub-routine be accessed by the same namespace with the access modifier of private?
Or does the access modifier need to be public or internal?
The only place I've seen the Friend modifier used is in the WinForms designer, as alluded to in Why is the modifier set to Friend in Winforms? and VB.NET: what does the 'friend' modifier do?. The Friend modifier appears to be an almost arbitrarily wide access level that was created to solve some historic architectural problem in VB, I just wonder if anyone has a meaningful continued use for it?
I have had some desires to expose methods only to a given namespace so as to roll the functionalities of a related collection of objects together and manage any of their non-thread-safe methods, while exposing the safe public methods to a wider scope in the same assembly. This access level does not exist yet Friend does. Possibly a corollary question then, is my usage of assemblies and namespaces at odds with what is intended?
[Code]...
I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.
View 2 RepliesI've got labels on my form using the following "Shift1Time1Label" to "Shift1Time8Label".I'm trying to get information from a access database and change the text of the labels.I'm getting the information, but having an "Object reference not set to an instance of an object" on the directcast to the label....
[code]...
I have made a vb.net application which has 63 forms. On each form label2 should contain the username using the application. The first form displayed to the user is the login form. When the user clicks the login button on this form the user name in all newly opened windows should appear inside label2. How can I do this?
View 3 RepliesPassing data between forms without any public methods or properties on the forms. everything but the "Controller" class, which I would like you furnish. I just changed the title from "Intermediate" to "Beginner" This solution is an example of the Observer Pattern. The "Controller" class is the "observed" class, which in this case means it publishes events.
' File Definitions.vb
Public Delegate Sub MessageDelegate(ByVal sender As Object, ByVal e As MessageEventArgs)
Public Class MessageEventArgs : Inherits EventArgs
Public Message As String
[CODE]...
The program should initially display Form1, and Form2. Clicking of the button on either form will modify the Title Text of both forms. I think that you will find the final end result to be pretty neat, as it works with any number of open forms not just two. I think asking for the Controller class is easier than asking for the code in the forms. My solution for Controller class has 7 lines of content, 9 lines if you include Class, EndClass. A minimal solution could achieved with only 4 lines of content, but it would a textbook example of bad programming.
What i want is :
There is one windows app ( made in .NET 3.5, VS2008, C# ) for Windows XP SP2 & SP3
generally users can change there IP or modify their IP Address.
Now,when my apps starts i dont want users to change there IP Address untill my app stops.
Is it possible to set a variable in my custom class for Private Read/Write access and Public Readonly access without creating Properties with Get and Set? In other words, from within my class I want full access and from my form I only want read access. Right now I declare my variable as either Private or Public to control Public read/write access. I tried googling my question a bit but I'm not sure what the correct terms even ar
View 5 RepliesPublic Sub mainlogin_Authenticate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles mainlogin.Authenticate
'Are the credentials valid?
If Membership.ValidateUser(mainlogin.UserName, mainlogin.Password) Then
'Has the password expired?
[Code]...
Error 6 'System.Web.SecurityUtils' is not accessible in this context because it is 'Friend'.
I want al(InitialStrength.Text) to be set as the variable iST so I'm typing this at the top of the page before all my subs:
Public Class CharacterSheet
Public iST As Integer = Val(InitialStrength.Text)
[code]....
but every time I do that and try to compile without even using the variabe, I get this error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."
Is it better to use friend or public forms in vb.net? What are the advantages of each?I notice when you import a vb6 project, the forms come in as friend, but when you add a new form in vb.net it is public. I have not seen any difference in the way they work, though, so I must be missing something.
View 3 RepliesI'm attempting to call an external public sub from another dll. I've added the dll as a reference and in VS Express 2010 it shows in my intellisense, however, it errors "Non-shared member requires object reference.[code]...
View 1 Replieshow to make a variable public to all forms within the application.Eg
Public MyPath = "C:"
can do for one form but not all
I have a string on my main form called String1. When I open another form, I need access to this value. In the form I open, I have always done something like:Dim NewString as String = Main.String1
This has worked in the past. Well, I ended up renaming my forms (from Form1 to Main) in the property window and it now when I type the above code, it does not list Main as a form. Nothing that I renamed seems to exist now.
my problem is that i have an MDI Parent form. it has lots of child forms. on my MDI Form i have the toolbar buttons Add, Delete and Save.all or most of the child forms, i created a custom public procedure Sub AddNew, Sub Delete and Sub Save.what i'm trying to do is when i click the AddNew in the MDI Form, it will run the custom public Sub AddNew of the currently ActiveMDIForm. i have tried...
DirectCast(Me.ActiveMdiChild, Form2.AddNew()
but i'm getting an error "Unable to cast object of type 'Form1' to type 'Form2'" if the currently ActiveMDIChild is not Form2.
[code].....
In vb.net, you can address a public variable from another form using the form name along with the variable.
form2.show
form2.k = 3
However, if you use a form variable to show an instance of the form, you must use that variable name to address the public variable. Two instances of the same form are displayed in the following example. The public variable k is assigned a value of 3 only in the first instance of the form, the one from form2.show. frm.k can be used to assign a value to the other form.
dim frm as new form2
form2.show
frm.show
form2.k = 3
Assuming only one instance of the form is shown in the application, is it reliable to address a public variable using the form name (form2.k), or is it better to show the form with a form variable and use that to refer to the instance of the form (frm.k)? Would the same answer apply to a property as well as a public variable?
I'm using VB.Net. I have a WPF User Control called "NavigationPanel" which I created with the Designer. By default, its scope is Public. When I change its scope to Friend in the file NavigationPanel.xaml.vb, I recieve the following error:
[Code]....
I am trying to create and add text to a file.When the code runs, sAppDirectory shows a subdirectory as indicated below, but an exception is thrown because the subdirectory doesn't exist. Windows Explorer shows a " . . . DocumentsMy Documents . . . " structure but the sAppDirectdory doesn't show the "My Documents" in the string. Where did it go?Is there a way I can keep this automatic rather than having to "hard code" the pathname?Or, how can I access the Public subdirectory for the output file(s) via an automatic method? See the code below.[code]....
View 6 RepliesI have the following code:
Public Function StoreFields()
Dim Lockbox, Cash_Deposit_Date, Batch_Number
Lockbox = Xdocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:tbl_GC100/@Lockbox").Text
[code].....
I have tested the variables in the Functions and the are correct.
I have a class which has various methods that I need to make public to only 1 other class. Is this possible? I don't want to make them public for everybody, just that 1 class.
View 1 Repliespublic sub show(as owner system.windows.forms.iwin32window) error
View 1 RepliesI have a Class with certain subs and functions declared as protected friends. From my understanding this should allow me to be able to access those subs and functions from anywhere in my project and yet it isn't working.
View 5 RepliesWhen adding a new control to the designer in Winforms, the modifier on the control is set to Friend, but the default modifier is Private (right clicking the property and resetting the modifier). Is there a setting to set the modifier to default (Private)?
View 2 RepliesI would like a answer to the following question: For instance:
You have a class called Main. This class created a object of another class called Math.
Class Math has a method called Calculate()
Class Main wants to call this method Calculate().
What kind of modifier should I use for the method Calculate()? I always used public but now I am not so sure... Friend seems to be working as well. What is the best way to do this?
Can we define a constructor with 'Friend' modifier?
Friend Class Reader
Friend Sub New()
End Sub
End Class
Yes, you read it right! Exchange Server 2000. I want to create a script that retrieve information(ie. Last Access Time) of all the files that are place within the public folder of the Exchange Server 2000.
View 2 RepliesI'm working on a simple base form in which all the other forms in the project will inherit. This base form only adds 5 properties (at the moment) dealing with painting a gradient background. The problem I'm facing right now is when I change a property on Form1 (the test form) and click run it doesn't show that change. I also checked the .designer.vb file and when I make a change it's not added to the code behind file, I'm at a loss right now to why.
[Code]...