.net - "Public Friend" Versus "Friend Friend"?
Apr 21, 2011
I've been reading about access modifiers in VB.Net lately, and there is something that I can't really understand: How do elements in a Class (or Module) inherit the modifiers of their enclosing block?For example, suppose you have a Friend class Bla in an assembly, with a public method Foo:
Friend Class Bla
Public Sub Foo
(...)
End Class
Does it behave differently than when Foo is set to Friend?
Friend Class Bla
Friend Sub Foo
(...)
End Class
View 1 Replies
ADVERTISEMENT
May 15, 2009
I can't make difference between public class and private class and friend and protected friend class.
View 1 Replies
Jun 18, 2010
Why is it that some components/controls will not be inherited visually in a child form if they are declared with the access modifier Friend vs when they are declared with Protected. For example, I've got a DataSet object in my Parent Form that was initially "Friend" (I drag and dropped it to the form, so it was shown as a control in the designer view), but I noticed that my Child Form did not inherit the control as expected. Once I changed it to "Protected", it showed up in my Child form as expected.I am aware that Protected allows the Child Form to modify the inherited control, but how exactly does this tie in to the issue I described above?
View 1 Replies
Jan 19, 2010
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 Replies
Nov 18, 2011
Is there a way to do something like this?
Public Enum CarMakes
Honda
BMW
Mazda
Friend Yugo
End Enum
I need to expose the the Enum to Public except for one of the items I just want to be available from inside the assembly.
View 1 Replies
Feb 27, 2009
I understand how the class modifiers work like public, private, protected, friend and protect friend. They are pretty straight forward. However my question is, if I have a class is marked as friend, what should the properties and methods be marked as? Friend or public? Does it matter? I just want my classes at the lowest exposure level that will let my program work properly and that is friend. If I understand correctly, the public properties of a friend class are available to all members of the assembly. Wouldn't that be the same access level if the properties were all friend properties?The reason that I ask is that using the autocomplete feature to make new properties (type property and hit tab) it creates the new properties with the public attribute.
View 4 Replies
Nov 27, 2010
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]....
View 1 Replies
Dec 17, 2009
Who knows, why in vb.net WinForm projects the designer by default use the Friend WithEvents attributes and in C# - private ones.
By ex, in a form.designer.
.cs
private Label Label1;
.vb
Friend WithEvents Label1 as Label;
For WithEvents is more or less clear(for using Handles, apparently). But why Friend in VB and private in C#...
View 4 Replies
Jun 30, 2009
I have class Aand BHow do i declare the class B as a friend of A?
View 4 Replies
Aug 9, 2011
I 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 Replies
Dec 20, 2010
I can think of the following tricks:
Read only wrapper - like ReadOnlyCollection. The friend keeps the pointer to the modifiable object, while everyone else can access only the wrapper.Write delegate - the friend gives the constructor of the object a reference to a delegate as one of the parameters, the constructor fills it with an address to a private method that can be used to modify the object.Reflection - obviously a bad idea. Included for completeness.Multiple assemblies - put your friends together in a separate assembly and set your modifier methods internal.Expose the modifiable object, but add comments to modifier methods "This is an infrastructure method - don't call it!"Nested classes.[code]...
View 2 Replies
Jun 1, 2010
As far as c/c++ is concerned ,friend functions are defined outside the classes and they are accessed without object name.But in vb.net how can i create friend functions like that ? Is the concept same here or its bit different than what was in c/c++ ?
View 11 Replies
Sep 14, 2010
When 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 Replies
Sep 23, 2009
I have a few classes (about 15 or so) in VB.net (2005) that I would like to be able to serialize to xml. Unfortunately they are labeled as friend classes and cannot be exposed outside of the assembly.The assembly is a dll that is a com interop plugin to a CAD system. I have set all of my classes as friends so that they are not exposed outside of the assembly for 3rd party use. I am wondering if I even need to do that. Setting the class to public would allow me to serialize things. However I don't want people linking to the assembly and using the classes.Should I even worry about other programs linking to my assembly? In fact I don't think there is a large chance of this happening. I just don't like the idea of having almost all of my classes with a public scope.Is there a way to make a friend class serializable?
View 2 Replies
Aug 13, 2011
Can we define a constructor with 'Friend' modifier?
Friend Class Reader
Friend Sub New()
End Sub
End Class
View 1 Replies
Oct 14, 2009
A friend at work is trying to write a piece of database software for an HND project and when adding his database file, he gets the below error message. I'm too much of a greenhorn to know what it means, can anyone make sense of it?
View 1 Replies
Aug 27, 2011
facebook friend add using regex,how? [code]
View 1 Replies
Mar 21, 2012
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]...
View 2 Replies
Sep 1, 2010
First of all let me say that while I was knowledgeable enough to create my program using VB-10 express I am by no means fluent in 'programming' speak .. so if you choose to help me please don't use technical jargon.. just explain as if you are talking to a 6 year old ..
Anyways I would like to give my program to some friends either by Email or via the internet (I have a website [url] (it is a wordpress blog) but I have no clue as to how I would get it onto my site.
I have attempted to Email the files .. first I had to change the file extension because Email would not send an .EXE file.. Then I tried to ZIP the files and send them via WINZIP but my recipients kept getting 'unable to open file' messages.
View 7 Replies
May 11, 2012
I am working on a VB Windows Form and I have a question here about initialize an array (friend variable)[code]But this didn't work and it thrown an exception says Object reference not set to an instance of an object.I am wondering how I can have the array initialized to size 4.
View 1 Replies
Jun 10, 2011
I'm playing around with VB.NET once again since college and I'm trying to recreate a program that GeekSquad uses called the MRI for a friend.Upon doing so, I have run into a few snags. The must present one is once I publish my application to a particular spot that also includes already setup folders with portable apps setup in them. I want to use Process.Start("App Path") where App Path is the drive letter of where the Custom Program exe is located and calling file Test1.exe in the test1 folder in the root.
View 3 Replies
Jul 13, 2011
I made a program for my friend, a patient database program using VS 2010. I'm worried if my program messes up she loses all the records. Here's what I remembered doing. Maybe you guys can identify how I can fix this or you can give ideas on how to avoid the same mistake.
1. I used Visual Studio
2. I made a VB Windows Forms Application
3. I made a Service-Based Database called Database1.mdf which is a Dataset Model
4. I chose save connection string to Database1ConnectionString
[code]....
She was glad with how simple it was cause I made it with Visual Studio. Now I dunno how to export the database file from her computer/copy of program to make a backup. I dunno what to do.I know I didn't ask for anything in return but if the program messes up I'd feel bad. 1k+ records already jesus christ and the program has like 74 columns/textboxes.
View 3 Replies
Feb 25, 2011
I'm currently trying to create a NEWID() function in my DataContext in LINQ using the solution here, however, when adding the partial class to my DataContext.vb or a separate DataContextPartial.vb, I get the error System.Data.Function is not available in this context because it is 'Friend'.
I've come across this when accessing data types before and that was in easy fix of setting it to Public, but I'm not sure where the properties for function could be or how to change them.The code I have is converted to VB.NET from the C# in the linked answer above:
Partial Public Class CMSModelDataContext
<[Function](Name:="NEWID", IsComposable:=True)> _
Public Function Random() As Guid
[code]....
View 2 Replies
Aug 17, 2009
I have an application that I originally wrote in MS Basic. It has since migrated to VB6 and then to VB Net. It works, but recently I have been unable to rebuild the project and an attempt to convert from VB6 has produced an error on converting and MSMaskEdBox as an array.
The most recent problem arises from the line of
Friend ExcelGlobal_definst As New Excel.Global
This enables me to pass data to an Excel spreadsheet from my project. If I leave a blank after New, VB Net presents me with a drop-down list, which includes I have recently tried to convert the project on my laptop and the above line of code produces an error. When I try to add a property(?) after New, Excel is not in the list of those available.
View 1 Replies
Jun 4, 2012
When I find examples online of VB.NET watch some functions use:
(Protected / Partial) & (Friend / Shared) & (Sub / Function) exp()
End (Sub / Function)
what is the difference?
View 1 Replies
Jul 2, 2010
When 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.
View 2 Replies
Feb 1, 2011
I am getting an error message: "Pervasive.data.sqlclient.v is not accessible in this context because it is 'friend.'" This error message appears when I hover the cursor over the "For Each v In qv" line in the following code:
[Code]...
View 3 Replies
Jan 2, 2011
Put the following two lines of code within a SUB or FUNCTION.>>
View 15 Replies
Jul 5, 2011
I'm trying to get a generic method working in VB.NET but I can't get the signature to accept a generic type parameter. I just get "'t' is not accessible because it is "Friend"".
My method signature is:
Public Shared Function GetOffset(ByVal coll As IEnumerable(Of t), ByVal offset As Integer, ByVal limit As Integer) As IEnumerable(Of t)
View 2 Replies
Dec 27, 2010
can anyone give me a simple example of how to list the friend list from Facebook to VB.net and what SDK should I install for VB.Net, I don't want to program using C# I saw that there is sth called SDKC#
View 2 Replies